ssh中DAO中 util工具类 经典代码

 

 

package com.cn.util;

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

public final class HibernateUtil {
	private static SessionFactory sessionFactroy;
	
	private HibernateUtil() {
	}
	
	static {
		Configuration cfg = new Configuration().configure();
		sessionFactroy = cfg.buildSessionFactory();
	}
	public static SessionFactory getSessionFactroy(){
		return sessionFactroy;
	}
	public static Session getSession(){
		return sessionFactroy.openSession();
	}
}


 

你可能感兴趣的:(ssh)