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

  

posted @ 2019-03-06 09:50  含苞待放会有时  阅读(227)  评论(0编辑  收藏  举报