I'm introducing progressively Hibernate in my system.
The system is a middleware that handles web service request.
For each request we get a connection from the pool and is them handed to the different DAOs to do their job with JDBC. The transaction is handled outside of the DAOs.
Now I'm introducing Hibernate so I create DAOs based on hibernate (working together with the existing ones), they receive a connection to create a session and then the different methods query or updates on that session.
Currently I'm not closing the sessions at all and it seems to work fine, since the connection and the transaction are managed outside Hibernate.
I think when the DAO is garbage collected the session and it's cache are too.
Are there any risks or memory leaks problems on doing this?
I've seen in the docs that the standard pattern is saving the session for each thread using a filter or similar but in my case that doesn't fit very well.
|