-->
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: Releasing connection after initializing lazy collection
PostPosted: Sat Nov 15, 2008 9:37 pm 
Newbie

Joined: Sat Nov 15, 2008 8:39 pm
Posts: 1
Hibernate version:
3.2 and 3.3

Hi everyone.

Here is my use case: I have a method with multiple hibernate reads (mostly getById type of reads). Execution of this method is happening outside of the transaction or in other words transaction was not started prior to the series of the "getById" calls.
For all getById calls I can see that connection is obtained from the pool and then released right after statement is done. And this behavior is fine and is what I want. The surprise comes when lazy collection is loaded. I can see that connection was taken, SQL query to load collection is completed, but connection is not released. Connection will be held until either session.close() or until the end of another getById call (or probably until some other event which aggressively releases connection) .

I have hibernate's connection release mode set to "after_transaction". This works just fine and if transaction is started prior to all read operations one connection is used for all of them and then connection is released at the end of the transaction. Again this is perfect and what I need/expect when I explicitly start transaction and need all reads in one transaction.

So I guess the problem is only with lazy collections loaded outside of the transaction. That’s when the connection release behavior is unpredictable.

Is this expected or is this a bug?

In short the behavior that I want to achieve is in the case transaction is not started I want all reads be made with "after_statement" connection release semantic and only if transaction is started then "after_transaction" semantic be applied. For simplicity sake let’s assume that I only have reads (no writes whatsoever).

Thanks a lot for attention.

-Nick


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.