Tuesday, July 17, 2012

private static SessionFactory sessionFactory=buildSessionFactory();





private

static SessionFactory buildSessionFactory() {

try {




SessionFactory sessionFactory =


new Configuration()




.configure(


"/com/aises/test/hibernate.cfg.xml")


//.addResource("/com/aises/test/VillageInformationFormDetailsReplica.hbm.xml")



.buildSessionFactory();

return sessionFactory;



}

catch (Throwable ex) {




// Make sure you log the exception, as it might be swallowed




System.

err.println("Initial SessionFactory creation failed." + ex);


throw new ExceptionInInitializerError(ex);




}
}

public static SessionFactory getSessionFactory() {


return sessionFactory;




}

public static void shutdown() {




// Close caches and connection pools



getSessionFactory().close();
}

No comments:

Post a Comment