hibernate封装Until工具类
public class HibernateUntil { private static SessionFactory sessionfaction; //一个web项目确保只调用一个sessionfactory所以 static { Configuration cfg=new Configuration().configure(); sessionfaction = cfg.buildSessionFactory(); sessionfaction.getCurrentSession(); sessionfaction.openSession(); } public Session openSession() { Session session = sessionfaction.openSession(); return session; } public Session getCurrentSession() { Session session = sessionfaction.getCurrentSession(); return session; } }