package kpi.asoiu.utils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtils {
private static SessionFactory session;
public static Session getNewSession() {
if(session == null){
session = new AnnotationConfiguration().configure().buildSessionFactory();
}
return session.openSession();
}
public static void close() {
if (session != null)
session.close();
session = null;
}
}