Does the fact that a Hibernate session might span several JTA transactions mean that the session must surround the transaction?
Which of the following are allowed?
1. Session surrounding
Code:
Session session = sessionFactory.openSession();
userTransaction.begin();
// Perform work
userTransaction.commit();
session.close();
2. Transaction surrounding
Code:
userTransaction.begin();
Session session = sessionFactory.openSession();
// Perform work
session.close();
userTransaction.commit();
3. Transaction "first"
Code:
userTransaction.begin();
Session session = sessionFactory.openSession();
// Perform work
userTransaction.commit();
session.close();
4. Session "first"
Code:
Session session = sessionFactory.openSession();
userTransaction.begin();
// Perform work
session.close();
userTransaction.commit();