Description of problem: Our EJB methods in demarcated by container-managed JTA transactions. Our Hibernate DAOs can and should participate in those transactions; however, they do not. We fetch (hibernate) session objects from our HibernateSessionFactory class. This class uses a thread local, which isn't necessary *if* we are using one of hibernate's session contexts. Every hibernate session context implementation is responsible for ensuring thread safety. After looking at the code some more, I finally saw it. We are not using hibernate's session context at all. To use hibernate's session context (be it thread local or JTA), you need to call SessionFactory.getCurrentSession(), but we explicitly create a new session with SessionFactory.openSession(). I had to poke around the hibernate source and the new hibernate "bible" to put this together. This is tied in with bug 453179. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
With things properly configured, we can altogether remove our HibernateSessionFactory class since Hibernate provides that behavior for us out of the box.
This bug has been fixed in a branch at https://svn.devel.redhat.com/repos/CSP/branches/developer-branches/jsanda/hibernate-testing.
This fix was moved into trunk a while back and subsequently also moved into the MR8 branch. It went out in the MR8 release.