Chủ Nhật, 29 tháng 1, 2012

[Hibernate 4] BuildSessionFactory - deprecated on Hibernate 4

Issue : sessionFactory = new Configuration().configure().buildSessionFactory();
--> It was deprecated with Hibernate 4.
Solutions:


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;
}

Không có nhận xét nào:

Đăng nhận xét