package com.supermap.zzsubcorp.LandManager.LandManagerEngine.util;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* <p>Title: HibernateUtil</p>
* <p>Description: </p>
* @author HanAnSheng
* @date 2018年8月11日
*/
public final class HibernateUtil {
private static SessionFactory sessionFactory;
private HibernateUtil(){
}
static{
Configuration cfg=new Configuration();
cfg.configure();//读取hibernate配置文件hibernate.cfg.xml,如果该文件不是这个名字或者没放在src下面,那么需要cfg.configure("xxxx.xml")
sessionFactory=cfg.buildSessionFactory();
}
public static SessionFactory getSessionFactory(){
return sessionFactory;
}
public static Session getSession(){
return sessionFactory.openSession();
}
}