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; } }}
添加回答
举报
0/150
提交
取消