public class MyHibernateSessionFactory {
private static SessionFactory sessionFactory;
private MyHibernateSessionFactory(){
}
public static SessionFactory getSessionFactory(){
if(sessionFactory==null){
Configuration config=new Configuration().configure();
ServiceRegistry serviceRegistry =new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
sessionFactory=config.buildSessionFactory(serviceRegistry);
System.out.println();
return sessionFactory;
}else {
return sessionFactory;
}
}
}
慕九州0120569
oldmee
相关分类