Hibernate - ServiceRegistryBuilder

前端 未结 9 1838
眼角桃花
眼角桃花 2020-12-28 08:30

I\'m just trying to learn Hibernate (version 4 final) but I have a problem when trying to create the session factory. Here is some code related to the problem:

hi

9条回答
  •  隐瞒了意图╮
    2020-12-28 08:53

    As of 4.3.0, even ServiceRegistryBuilder has been deprecated. This is how you would want to go about it

    Configuration cfg=new Configuration().configure();
    StandardServiceRegistryBuilder builder= new StandardServiceRegistryBuilder().applySettings(
                cfg.getProperties());
    SessionFactory factory= cfg.buildSessionFactory(builder.build());
    

    And also you would have to import org.hibernate.boot.registry.StandardServiceRegistryBuilder instead of org.hibernate.service.ServiceRegistryBuilder

提交回复
热议问题