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