package com.anrongtec.utils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* 工具类。
*
* @author CAOXIAOYANG
*
*/
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory(){
return sessionFactory;
}
public static Session getSession(){
return sessionFactory.openSession();
}
}
原文地址:https://www.cnblogs.com/CAOXIAOYANG/p/8861631.html
时间: 2024-10-11 06:34:22