-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate session closed, without transaction committed
PostPosted: Fri Sep 21, 2007 10:55 am 
Newbie

Joined: Fri Sep 21, 2007 10:43 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.