Are you sure:
Code:
null != session && session.isOpen()
is being evaluated to true and session.close() is being executed. Put some logging here.
Where is your tx start() and commit()? What context (J2EE server, standalone...) are you invoking this in?
Also - your session.close() should be in a finally block otherwise if an exception is encountered, the session will not be closed.
The 'pattern' is (from the manual):
Code:
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
// do some work
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}