HibernateUtils.java
package art_test;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtils {
static SessionFactory sf;
static{
Configuration configure = new Configuration().configure();
sf = configure.buildSessionFactory();
}
public static Session getSession(){
Session s = sf.openSession();
return s ;
}
public static Session getCurrentSession(){
Session s = sf.getCurrentSession();
return s;
}
public static SessionFactory getSessionFactory(){
return sf;
}
public static void close(){
sf.close();
getCurrentSession().close();
}
}