Hibernate session management is a little tricky for new users.
There are two ways to obtain a session:
The first way requires the following line in the hibernate.cfg.xml:
Seems if you use the first method, when you commit a transaction by calling tx.commit(), the session will be closed automatically. This can introduce error if you try to close the session again.
Whereas if you use the second method, a transaction will not close the session after commit, you will have the chance to manually close the session.
The above comments applies for hibernate 3.1, I used it with Tomcat5.5 datasource on Java1.4