Okay when I read through Hibernate Documentation i found this piece of code : (Chapter 1 pg.6)
Code:
private static void closeSession() throws HibernateException {
logger.debug("CLOSING SESSION");
Session currSession = (Session) session.get();
session.set(null);
if (currSession != null) {
logger.debug("CURR SESSION != NULL");
try {
currSession.close();
} catch (Exception err) {
err.printStackTrace();
} finally {
try
{
currSession.close();
}
catch(HibernateException hibEx)
{
throw hibEx;
}
}
}
}
Well I added some extra debugging statement and try-catch..
Okay but here is my question :
1.Why does the code do session.set(null);
2. if currSession is null then how do we close the connection ??
Thanks for any hints,comment, or help ^____^