Hibernate buildSessionFactory () is not used for arguments (ServiceRegistry)

I am new to Hibernate and I am trying to create a session manager. Here is the code to create an instance of SessionFactory :

 Configuration configuration = new Configuration().configure(config); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings( configuration.getProperties() ).buildServiceRegistry(); SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; 

When I run this in eclipse, I get the following compilation error: The method buildSessionFactory() in the type Configuration is not applicable for the arguments (ServiceRegistry).

Using the latest version of Hibernate, shouldn't buildSessionFactory accept the ServiceRegistry argument?

+4
source share
1 answer

Make sure you are using the latest version. You can run the following line of code to check the version of Hibernate.

 System.out.println(org.hibernate.Version.getVersionString()); 
+1
source

Source: https://habr.com/ru/post/1445629/


All Articles