Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0
I am working with Weblogic 8.1 in a clustered environment. I am using the HibernateUtil class as specified in the Hibernate in Action book. For some reason I can not invoke the HibernateUtil.commitTransaction. When I try I get an Exception thrown stating the Session is closed. The following code however seems to work:
Code:
Session sess = HibernateUtil.getSession();
Transaction tx = sess.getTransaction();
sess.saveOrUpdate(myObject);
tx.commit();
...
HibernateUtil.closeSession();
When the Transaction tx = sess.getTransaction() is replaced with HibernateUtil.beginTransaction and tx.commit() with HibernateUtil.commitTransaction() an Exception is thrown. If I remove the HibernateUtil.commitTransaction call and use sess.flush and then just close the transaction this seems to work but our changes to the database are not always saved. This has become difficult to troubleshoot because the problem is intermittent and we are never really sure now when/if we have fixed the problem. We are planning to go with the code above in the code box since the explicit commit call seems to work. My question is does anyone know if the HibernateUtil class has problems operating in a Weblogc cluster? Would the use of the local thread variables cause a problem?
Michelle