*ReturnstheThreadLocalSessioninstance. Lazyinitialize
*the<code>SessionFactory</code>ifneeded.
*
* @returnSession
* @throwsHibernateException
*/
publicstatic Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}
return session;
}
/**
* Rebuildhibernatesessionfactory
*
*/