hibernate 的工具类

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();
}
}

posted @ 2018-04-17 08:55  Sunray0330  阅读(124)  评论(0编辑  收藏  举报