package com.cn.utils;
/**
* hibernate工具类
* @author 龚道松
* @date 2018年8月5日 下午8:16:23
* @version v.0.1
*
*/
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtils {
// 1.创建工厂对象;
private static SessionFactory sessionFactory;
// 2.初始化工厂对象;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
// 3.获得Session;
public static Session getSession() {
return sessionFactory.openSession();
}
//4获得session
public static Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
}
hibernateutils
猜你喜欢
转载自blog.csdn.net/gdsgdh308227363/article/details/81629635
今日推荐
周排行