public class HibernateUtils { private static SessionFactory sf; static{ sf = new Configuration().configure().buildSessionFactory(); } public static SessionFactory getSessionFactory(){ return sf; } public static Session getSession(){ return sf.openSession(); } public static void closeSession(Session session){ session.close(); } public static void closeResource(Session session){ session.close(); sf.close(); }}