-->
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.  [ 5 posts ] 
Author Message
 Post subject: Multiple transactions using the same session and rollback
PostPosted: Wed Oct 01, 2003 5:44 am 
Newbie

Joined: Wed Oct 01, 2003 5:29 am
Posts: 4
Hi all,

A have a question regarding the use of transactions. Is it safe to have several (non simultaneous) transactions in the scope of the same session ? I have serched the forums and the first conclusion would be - yes, it is possible - but we have a problem which we are thinking is related to this issue. The problem is that it is possible to have several transactions which are commiting themselves but in our case we would like to continue with the next transaction even if the previous one was rolled back. The problem here is that the session is never flushed on rollback and it seems that the database operations are still performed on the next transaction commit. A manual flush before the rolback solves this problem but it seems to be a little bit expensive. Is it possible/sane to have a possiblity to clear the session (manually or even better - automatically) on rollback ?

Thanks,
Peter.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 5:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You should not reuse the session after a rollback. You -may- use it across several -successful- transactions. (This is a kind-of "advanced" usage; Christian Bauer is the only guy I know who is actually doing this kind of thing in a real application.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 6:03 am 
Newbie

Joined: Wed Oct 01, 2003 5:29 am
Posts: 4
Thank you Gavin. I was expecting it to be possible as when you work directly with JDBC connections. I think I understand the problem with implementing this behaviour - the session cache remains inconsistent. For us it was interesting to have this as it is more transparent - we don't have to open another session if the transaction rollbacks and continue to use the same session as when the transaction succeeds. Maybe an Session.evictAll method would do the trick ? Anyway we will keep in mind this issue and will try to have a different code organisation.

Regards,
Peter.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 6:07 am 
Newbie

Joined: Wed Oct 01, 2003 5:29 am
Posts: 4
I was looking through the hibernate beta3 version and there is a method Session.clear(). It seems to do exactly what I have asked for. Do you think using this method would allow the session reuse after a rollback ?

Thanks,
Peter.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 6:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh, sure, if you call clear(), the Session completely loses all state.


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

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.