/**
* A static method with returns Hibernate Sessoin Object.
*
* @return {@link Session}
*/
public static Session getSession() throws HibernateException {
Session appSession = sessionFactory.openSession();
try
{
if(appSession.connection().isClosed()||!appSession.isConnected()||!appSession.isOpen()){
System.out.println("Session Closed, Creating Session again...");
appSession.reconnect(appSession.connection());
}
}
catch (Exception e) {
System.err.println("Got Problem while getting Session from Factory:"+ e.getMessage());
e.printStackTrace();
}
return appSession;
}
* A static method with returns Hibernate Sessoin Object.
*
* @return {@link Session}
*/
public static Session getSession() throws HibernateException {
Session appSession = sessionFactory.openSession();
try
{
if(appSession.connection().isClosed()||!appSession.isConnected()||!appSession.isOpen()){
System.out.println("Session Closed, Creating Session again...");
appSession.reconnect(appSession.connection());
}
}
catch (Exception e) {
System.err.println("Got Problem while getting Session from Factory:"+ e.getMessage());
e.printStackTrace();
}
return appSession;
}
No comments:
Post a Comment