-->
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: Hibernate release mode
PostPosted: Fri Sep 28, 2007 12:44 pm 
Newbie

Joined: Wed Dec 20, 2006 7:43 am
Posts: 1
What does release mode mean and what impact does it have?

If I am using jtaTransaction manager with a "read committed" isolation level, if I start a transaction will it not then fetch a connection from the pool and assign it to the session for the duration of the session?

It could do this lazily and that would make more sense and it would also mean that the release mode would come into play.

Release mode of "on_close" is simple, the connection is held for the life of the session and only released when the session closes.

But after_transaction and after_statement are a little nebulous.

If I'm only reading from the persistent store then it makes sense that after each statement the connection would be released and it could be made available to other connections, but if I then do an update on that session and a flush occurs, from then on, I have to keep the same connection surely? Can other sessions then use that one to read with?

The documentation says that I can only use after_statement if I can get back the same connection again - but in this case, surely some other session could not use that transaction to run update/inserts on? The two will interfere with one another? So do I gain anything by using after_statement release mode in this case?

Finally, my application, even though it is using a jtaTransaction manager defaults to on_close release mode. I think this is because I'm demarcating transactions with spring and not explicitly setting the transaction manager on the session factory. I defer the transaction manager creation till later.

How inefficient is it to use the on_close release mode rather than other recommendations?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 28, 2007 4:38 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
You definitely don't want ON_CLOSE. The manual IMHO is pretty clear about what each of these mean. I'm not sure what pool & TX manager you're using, but for JBoss AS it is important to use AFTER_STATEMENT as the JCA DataSource handles the actual caching and tracking of connections in a transaction.

http://www.redhat.com/docs/manuals/jbos ... Modes.html

Unless you've got a pretty crazy use case, the default (AUTO) is going to pick the right strategy based on ConnectionProvider and transaction lookup configuration.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject: It doesn't really answer the question...
PostPosted: Mon Oct 01, 2007 7:20 pm 
Newbie

Joined: Mon Oct 01, 2007 6:39 pm
Posts: 2
I read the cited section in manual and thought it over thoroughly before coming to this forum and was bothered by the same question as mwiles. Of course, I can just set release mode to after_statement as the manual suggests and not bother, but I'd like to understand what real implications does it have and I can't see how it could help.

I never heard of JDBC connections supporting multiple concurrent transactions; if a datasource returns the same connection to two transactions, even after the first one releases it (but before it's completion), then only one of them could be permitted to use it to modify data without violating isolation. This would mean that all the time we'd be seeing errors caused by a transaction trying to execute a DML statement on a connection already used by another transaction.

I guess the data source could try to return the same connection to a second transaction before the transaction that used and released it completes only when both have oracle's isolation level of READ_ONLY or in a similar situation. Even then, one transaction could (or couldn't it?) change the isolation level explicitly.

My best guess would be that releasing the connection doesn't return it to the pool, but releases all resources associated with executed statement (resultsets, etc.), but it's NOT what the reference says.

Could anybody savy enlighten me what advantage can I really get and in what situations (what AS, for example) ?


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.