从这里看的
http://hi.baidu.com/aurorapolaris/item/dfb8452b21401e85af48f5d9
hibernate3中是这样写的:
private static final SessionFactory sessionFactory = newConfiguration().configure().buildSessionFactory();
hibernate4中可以这样写:
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
private static SessionFactory configureSessionFactory()throws HibernateException{
Configuration configuration =new Configuration();
configuration.configure();
serviceRegistry =new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
http://hi.baidu.com/aurorapolaris/item/dfb8452b21401e85af48f5d9
hibernate3中是这样写的:
private static final SessionFactory sessionFactory = newConfiguration().configure().buildSessionFactory();
hibernate4中可以这样写:
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
private static SessionFactory configureSessionFactory()throws HibernateException{
Configuration configuration =new Configuration();
configuration.configure();
serviceRegistry =new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}