-->
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.  [ 2 posts ] 
Author Message
 Post subject: current_session_context_class as thread and connection pool
PostPosted: Wed May 30, 2007 7:20 pm 
Newbie

Joined: Sat Apr 21, 2007 9:48 pm
Posts: 9
If we use current_session_context_class as thread; Hibernate document says that once thread is DONE; hibernate automatically closes the session.
But what I noticed is that hibernate does an extra optimization. Hibernate closes the Session only if it is DIRTY (i.e. if any updates are done on it) else if session was used only for select queries ; it does not return session (DB connection ) to the pool. And reuse the session for next request getCurrentSession().

I am using c3p0 connection pool. To ensure reliable DB connection; I set all parameters like idleTime (see if connection is lieing idle in the pool), testConnectionOnCheckout (test connection whenever checksout from pool).
As hibernate gets the connection from pool and keep in its own cache until and unless the session gets dirty; hence connection pool is not able to close them after idleTime (though actually connection might be idle in Hibernate session pools) or not able to do testConnectionOnCheckout(as hibernate doesnt checkout from pool again and again.)

Hence, though connection pool feels everything is fine but still a connection in hibernate cache might be already invalid (MySQL closes connection after every 8 hrs)

Anyone faced this problem before ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 4:15 am 
Beginner
Beginner

Joined: Sun Nov 19, 2006 6:18 am
Posts: 28
I had faced the same problem.There were some sessions in my code which got left open by mistake.On closing them, i did not face this problem again.


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