This content has been marked as final.
Show 1 reply
-
1. Re: hibernate and jboss transactionmanager
julesverne Mar 2, 2006 3:58 AM (in response to julesverne)I picked this from the net...
However, in the context of a larger J2EE application, you'll likely want your Hibernate objects to take part in an existing JTA transaction. This would be the normal case if you wanted to access Hibernate objects in a session bean, for example.JBoss provides the org.jboss.hibernate.session.HibernateContext class as the integration piece that does this. The getSession method returns a Hibernate session that is linked to the current JTA transaction. Naturally this requires that a JTA transaction exist prior to the call. The following code illustrates the use of getSession.
Session hsession = HibernateContext.getSession("java:/hibernate/ExampleEmptorSessionFactory");
When you get the Hibernate session in this manner, you don't need close the Hibernate session or manage a hibernate transaction. You can be sure that all access to the Hibernate session from the current transaction will see the same state, and you can know that your Hibernate access will be committed to the database or rolled back along with the larger JTA transaction.
is this the only way....
thnx