hibernateUtil工具类的封装



package com.lq.util;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


/**
 * Hibernate工具类
 * 
 * @desc: hib04
 * @author:刘庆
 * @version: v1.0
 */
public final class HibernateUtil {


private static SessionFactory sessionFactory;


static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}


private HibernateUtil() {
throw new AssertionError();
}


public static Session getSession() {
return sessionFactory.getCurrentSession();
}


}

你可能感兴趣的:(hibernateUtil工具类的封装)