-->
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.  [ 3 posts ] 
Author Message
 Post subject: Sessions and Transactions
PostPosted: Mon Mar 14, 2005 3:44 pm 
Newbie

Joined: Wed Dec 29, 2004 3:45 am
Posts: 7
Location: Leuven, Belgium
Why is the scope of a transaction different than the scope of a session? In other words, why can I have multiple transactions on a single session?

I don't really see a use case where it would be safe to have several transactions on a single session since a transaction commit will flush the session, possibly committing changes to dirty objects. Those that ever tried "open session in view" know that this can lead to all kinds of unwanted side effects.

It seems that to be save and deterministic you should begin a transaction when you create a session and close the session again when the transaction is committed or rolled back (for rollback the docs clearly state that you should throw away the session). Is this a best practice?

Erwin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 6:46 am 
Newbie

Joined: Wed Dec 29, 2004 3:45 am
Posts: 7
Location: Leuven, Belgium
Anybody? This must be a pretty dry question :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 7:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that something isnt good in all cases doesnt mean it shouldnt be possible ,)

but anyhow...having a long session with multiple short transactions is in some cases a good thing when having a well defined application transaction.

I know that this scenario in some cases are very usefull in e.g. swing applications. (together with some clever usage of evict,refresh etc.)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.