-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: session.close() not called in named queries of GenericDaoHib
PostPosted: Fri Apr 20, 2007 4:39 pm 
Newbie

Joined: Fri Apr 20, 2007 4:31 pm
Posts: 2
For finder methods on the dao's supported by GenericDaoHibernateImpl, GenericDaoHibernateImpl does not properly close the connection.

For example, if you have an interface:

Code:
public interface MyDao extends GenericDao<MyObject, Long> {
    List<MyObject> findByStr(String value);
}


The method on GenericDaoHibernateImpl that supports the findByStr is:

Code:
public List<T> executeFinder(Method method, final Object[] queryArgs) {
        final Query namedQuery = prepareQuery(method, queryArgs);
        return (List<T>) namedQuery.list();
}


I don't see where the session gets closed?

What's the best way to solve this problem or am I missing something fundamental?

Michael


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
DAOs neither open nor close Sessions. That's the job of the client of the DAOS, or the job of the client of the DAOs wrapped in an interceptor that handles the Session.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 5:39 pm 
Newbie

Joined: Fri Apr 20, 2007 4:31 pm
Posts: 2
But it appears that the save/update methods of the GenericDaoHibernateImpl appear to be closing the session via the spring org.springframework.orm.hibernate3.HibernateTemplate class?

From the javadocs:

Quote:
* <p>The central method is <code>execute</code>, supporting Hibernate code
* implementing the HibernateCallback interface. It provides Hibernate Session
* handling such that neither the HibernateCallback implementation nor the calling
* code needs to explicitly care about retrieving/closing Hibernate Sessions,
* or handling Session lifecycle exceptions. For typical single step actions,
* there are various convenience methods (find, load, saveOrUpdate, delete).


Please let me know if I'm reading this wrong?

Michael


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 2:05 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Don't use the Spring stuff. Read http://hibernate.org/42.html and all pages linked from this page, including the DAO page. If you want to use the Spring wrappers (I wouldn't know why), ask on the Spring forum.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.