-->
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 = thread and Junit tests
PostPosted: Thu Sep 16, 2010 9:55 am 
Newbie

Joined: Mon Jun 07, 2010 7:50 am
Posts: 8
Hello,

I have a problem testing a webservice that uses hibernate to persist data.
my Hibernate.cfg contains this property:
Code:
<property name="current_session_context_class">thread</property>


So If I understand it correctly this means that each thread gets it's own session from the sessionFactory. So each request-response is a new session. This works ok in a request, response environment.
But if I run my JUnit tests(over 100+) in my testsuite then all tests are run in a single thread. This causes that each time I close a session and open a new one for a new test, that also a new database connection is made, but the old connections are not released. And when my DB hit 100 connection I get a "Too many clients exception".
I could change the connection limit to say 200, but this is just making the exception come at a later moment.

How can I test my code insuch a way that unused DB-connection will be released?

thanks


Top
 Profile  
 
 Post subject: Re: current_session_context_class = thread and Junit tests
PostPosted: Tue Sep 21, 2010 3:44 am 
Newbie

Joined: Mon Jun 07, 2010 7:50 am
Posts: 8
does anyone have an idea?


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.