Hello,
I'm using Hibernate 3.5.3 with the integrated jpa library for my JSF application. between Hibernate and the MySQL database I'm using c3p0 as suggested by many users. Before c3p0 I used dbcp but that gave exactly the same issues.
The issue is that I see "numBusyConnections" in c3p0 with hanging connections. I clean them from within c3p0 after 1800 seconds (unreturnedConnectionTimeout) but why are they there in the first place? c3p0 lets you dump stacktraces from creation time and so I found out that the connections are "checked out" by my 'long living' entity manager. That entity manager is created as soon as the user wants to change something on the screen and cleared as soon as the changes are submitted by the user and committed to the database. So 'long living' is just a couple of seconds, the time the user needs to read the data and make his changes on the web page.
Problems I see are: - I'm using one entity manager for all fields on the screen. The browser can request multiple fields simultaneously and so multiple threads do use the same entity manager concurrently for reading data from the database. But I don't think that this could be done differently because the jsf page uses things like #{employee.appointments} and #{employee.phonenumbers}. Those have to access the database through the persistence proxy and do so with multiple theads at the same time. - bug in entity manager??? This should never leave a connection used after the query is done. It all started as soon as I started using the Hibernate JPA library instead of the ejb3-persistence.jar.
Thank you very much for any help!!! Any pointer where to look is very welcome.
MAG, Milo v/d Zee
|