Hi,
I have a question regarding the Hibernate sessions/transactions. I'm familiar how it should be done, but I have a code which doesn't rollbacks the transactions, but closes the session in the finally block. I was wondering if an exception occurs, the session.close will automatically roll back the transaction?
The code looks like this:
try {
currentSession = databaseSession.openSession();
Transaction transaction = currentSession.beginTransaction();
.... do something.
transaction.commit();
} finally {
if (currentSession != null && currentSession.isOpen()) {
currentSession.close();
}
}
I know that there should be a rollback in the catch block, but I'm courious what happens in the code above in case of an exception. As you can see there will be no cimmit/rollback only a session.close().
Thank you in advance,
Botond.
|