That's exactly what I expected.
But I have experienced that Hibernate does not close the session after a transaction is committed or rolled back. If I begin antoher transaction after committing one transaction, hibernate uses same session. An explicit session.close() is required to close the session. I am using Hibernate 3.
Another issue with this approach is that all developers might not commit() or rollnback() the transaction after use. E.g. if you are querying the database and not doing any dml operation, you might not issue a commit() or rollback() after querying.
Hibernate binds the session with thread. Threads are reused by webserver. Thus if the session bound to the thread is not closed at the end of request, the session will be reused by next request serviced by the same thread.
Thus, it is safe and reliable to unbind the session at the end of every request. I am using hibernate 3 in my project.
_________________ Let us work this out.
|