This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Sridhar Santhanakrishnan wrote:When you comment the line and run the application, are the changes saved to the database when the transaction is commited?
This will not demonstrate whether the session was closed.
It depends on your sesison management configuration. If you have an interceptor or use transaction scoped sessions then commiting the transaction will close the session (assuming you did not open it explicitly in your transaction and instead used the current session). If you don't then it wont.
When you say session.commit() -- if any CRUD operation performed on a row; then that particular transaction after the CRUD operation will be committed in the DB.
When you say session.close() -- the session will be closed instantly.
May be you might have accessed any relevant code pertaining to that session after saying session.close();