0

buildSessionFactory已从休眠中弃用。我在用

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

但它说该功能已被弃用。什么是新的?请告诉我。

4

1 回答 1

0

buildSessionFactory()已在 Hibernate 4 中弃用,改为
使用buildSessionFactory(ServiceRegistry serviceRegistry)

下面也这样做:-

 Configuration configuration = new Configuration();
    configuration.configure();
    ServiceRegistry serviceRegistry= new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
    SessionFactory sessionFactory= configuration.buildSessionFactory(serviceRegistry);
于 2013-08-14T08:03:40.713 回答