Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 453180 - Hibernate DAOs Do Not Participate in JTA Transactions
Summary: Hibernate DAOs Do Not Participate in JTA Transactions
Alias: None
Product: JBoss Customer Support Portal
Classification: Retired
Component: Web-General
Version: 1.3.9
Hardware: All
OS: All
Target Milestone: ---
: ---
Assignee: JBoss CSP Bug Watch List
QA Contact:
Depends On: 453179
Blocks: HibernateIssues
TreeView+ depends on / blocked
Reported: 2008-06-27 18:22 UTC by John Sanda
Modified: 2009-02-05 21:13 UTC (History)
1 user (show)

Fixed In Version: MR8-CSP
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2009-01-30 17:39:24 UTC
Type: ---

Attachments (Terms of Use)

Description John Sanda 2008-06-27 18:22:18 UTC
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:
Actual results:

Expected results:

Additional info:

Comment 1 John Sanda 2008-06-27 18:26:09 UTC
With things properly configured, we can altogether remove our
HibernateSessionFactory class since Hibernate provides that behavior for us out
of the box.

Comment 2 John Sanda 2008-07-24 18:39:20 UTC
This bug has been fixed in a branch at

Comment 3 John Sanda 2009-01-30 17:39:24 UTC
This fix was moved into trunk a while back and subsequently also moved into the MR8 branch. It went out in the MR8 release.

Note You need to log in before you can comment on or make changes to this bug.