Joined: Sat Mar 03, 2007 4:13 pm Posts: 1
|
Hi All,
I am using Hibernate 3.4. GA and had a question about the behavior of the EntityManagerFactory close() method. The way I use Hibernate is that I create a single EntityManagerFactory and then use a Factory pattern to lookup an EntityManager from a ThreadLocal and if one does not exist I create one. In order to avoid using a stale EntityManager I check the return value of the isOpen() method on it. When running my unit tests I noticed that I am properly closing the EntityManagerFactory but the EntityManagers created from it still return true for the value of their isOpen() method. Reading the javax.persistence JavaDocs it indicates that closing an EntityManagerFactory should close all resources associated with it including all EntityManager instances created from it. Using a Java debugger I was able to observe that an EntityManager instance returned true from the isOpen() method but the the SessionFactoryImpl that created was closed.
Has anyone else encountered this issue?
Thanks!!!
|
|