hibernate 的工具类

Posted caoxiaoyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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();
}
}























以上是关于hibernate 的工具类的主要内容,如果未能解决你的问题,请参考以下文章