Hello,
Hibernate 3.1
I deploy it with a hibernate.cfg configured for JTA
Code:
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
The HibernateJTFilter of the caveeatemptor and
http://hibernate.org/42.html proposes the following code:
Code:
try {
UserTransaction tx = (UserTransaction)new InitialContext()
.lookup("java:comp/UserTransaction");
tx.begin();
// Do some work
tx.commit();
}
catch (RuntimeException e) {
tx.rollback();
throw e; // or display error message
}
I used the following, which also seem to retrive a UserTransaction. Did I overlooked something or is it just the same.
Code:
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
// Do some work
session.getTransaction().commit();
Regards Sebastian