-->
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.  [ 4 posts ] 
Author Message
 Post subject: when does the session retrieve a connection from the pool?
PostPosted: Wed Jan 04, 2006 10:00 am 
Newbie

Joined: Mon Dec 27, 2004 3:47 pm
Posts: 12
I'm wondering when the session actually obtains the connection from the connection pool, b/c i'm seeing some situations when i "clean up" meaning flush(), commit() and close() the session, i'm getting an error on weblogic 8.1sp2 saying that the connection is no longer available.

the connections are pooled internally to weblogic using jndi set up in the context.xml file and this situation doesn't occur all the time, but say 1-in-10 times. The pool size i have set up is 25, which should be plenty. i've got the sessions bound to the thread-local on the httprequest, and the transactions aren't long running, so i don't believe that's the trouble, especially since more intense transactions don't always get this issue, but it can happen to even the most simple database insert

it's as if hibernate goes to use the connection that it assumes it already has, and weblogic seems to have reclaimed it so hibernate is blindsided by the fact that the connection is no longer there.

i'm just wondering if hibernate delays obtaining the connection until the very end (i.e., when it's ready to flush(), and write to the db) or if when the session is created, it retrieves the connection from the pool

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 12:32 pm 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
Are you supplying your own connections to the Session? I guess so if you are using WebLogics connection pool. Maybe this might help you debug the problem... inside your getSession method where you return the thread-local call session.reconnect(), it is deprecated but it might give insight into what is going on. You could also add some debug code by using session.isConnected().

Not a solution, but hope it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 9:26 pm 
Newbie

Joined: Mon Dec 27, 2004 3:47 pm
Posts: 12
no, i'm not explicitly supplying my own connection. i'm simply getting the JNDI from weblogic, and then using spring's bean factory to inject it all together. thanks for the suggestion, however.

i'm just wondering when the session obtains the connection? initially when the session is created? or does the session delay obtaining the connection until it's absolutely necessary?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 3:16 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
On looking up the source, it looks like the connection is obtained when the statement is prepared, which is at the very end. This is the case *unless* the user supplies a connection in which case it is obtained during Session Creation.
This makes sense as Hibernate doesnt have to lock connections unless its absolutely necessary to use them.


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