Я новый, чтобы зимовать и пытающийся использовать его, таким образом, для изучения цели некоторые, где я использую API Критериев и некоторых где HQL.
Мое заявление хорошо работает, но проблема после выполняет 5-6 раз, больше связи JDBC не открыто, и применение висит там.
в регистрациях это говорит... Открытие Связи JDBC...... thats это.
Я прочитал немного докторов, и это говорит, что это из-за не выпуска Сессии, как только это открыто.
Это - функции, которыми я управляю.
public List getAllPlaces() {
Session session = getSession();
Criteria cr = session.createCriteria(Place.class);
List ls= cr.list();
session.close();
return ls;
}
public List getAllUser() {
Session session = getSession();
Criteria cr = session.createCriteria(User.class);
List ls= cr.list();
session.close();
return ls;
}
public List getAllCarpooler() {
Session session = getSession();
Criteria cr = session.createCriteria(Carpooler.class);
List ls= cr.list();
session.close();
return ls;
}
public List getAllSourceToDestinationDetailsbyCarpooler(
Carpooler carpooler) {
Session session = getSession();
Criteria cr = session.createCriteria(SourceToDestinationDetails.class);
cr.add(Expression.eq("listOfSourceToDestinationDetails",carpooler));
List ls= cr.list();
session.close();
return ls;
}
public List getExactMatchCarpooler(String from, String to) {
log.debug("Request received for fetching Exact match Carpooler.");
List listOfFinalCarpooler = new ArrayList();
List list = null;
try{
list = getHibernateTemplate().findByNamedQueryAndNamedParam("findExactMatchingCarpooler", new String[]{"source","destination"}, new String[]{from,to});
if(list!=null){
log.debug("Fetched Exact match carpooler list is :"+list.toString());
for (int j = 0; j < list.size(); j++) {
Object[] l = (Object[])list.get(j);
Carpooler c = (Carpooler)l[0];
SourceToDestinationDetails std = (SourceToDestinationDetails)l[1];
Carpooler c1 = new Carpooler();
c1.setCarpoolerCreationDate(c.getCarpoolerCreationDate());
c1.setCarpoolerId(c.getCarpoolerId());
c1.setDrivingLicenceNumber(c.getDrivingLicenceNumber());
c1.setUser(c.getUser());
c1.setListOfVehicleDetails(c.getListOfVehicleDetails());
c1.setUserType(c.getUserType());
List listOfSourceToDestinationDetails =new ArrayList();
listOfSourceToDestinationDetails.add(std);
c1.setListOfSourceToDestinationDetails(listOfSourceToDestinationDetails);
listOfFinalCarpooler.add(c1);
// log.debug("Carpooler is :"+c.getCarpoolerId());
// log.debug("SourceToDestinationDetails is :"+std.getSourceToDestinationId());
}
}else{
log.debug("List is null");
}
log.debug("Returning back from fetching Exact match Carpooler");
return listOfFinalCarpooler;
}catch(Exception e){
log.error("Exception Occurred while fetching Exact Match Result :"+e.getMessage());
}
return null;
}
Регистрации
2012-12-28 10:32:33,529 DEBUG http-8080-4 [DashboardController.getLoginPage1] - Fetching list of all user, to display count on home page.
2012-12-28 10:32:33,529 DEBUG http-8080-4 [SessionFactoryUtils.doGetSession] - Opening Hibernate Session
2012-12-28 10:32:33,530 DEBUG http-8080-4 [SessionImpl.] - opened session at timestamp: 13566709535
2012-12-28 10:32:33,531 DEBUG http-8080-4 [AbstractBatcher.logOpenPreparedStatement] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-12-28 10:32:33,531 DEBUG http-8080-4 [ConnectionManager.openConnection] - opening JDBC connection
Может кто-то, пожалуйста, вести меня, где я иду не так, как надо.