Spring JPA Data Java Config HibernatePersistence.class

HibernatePersistence.class is deprecated. What should be the alternative for this code?

import org.hibernate.ejb.HibernatePersistence
@Bean  
        public LocalContainerEntityManagerFactoryBean entityManagerFactory() {  
                LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();  
                entityManagerFactoryBean.setDataSource(dataSource());  
                entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);  
                entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));  

                entityManagerFactoryBean.setJpaProperties(hibProperties());  

                return entityManagerFactoryBean;  
        } 
+4
source share
2 answers

It should be.

org.hibernate.jpa.HibernatePersistenceProvider

As a supplier

http://docs.jboss.org/hibernate/orm/4.3/javadocs/

+6
source

Your code is ok. You do not need alternative solutions. The problem is that you missed the hibernate entity manager jar library [or the hibernate-entitymanager maven dependency if you use maven as your building project]. Add the hibernate-entitymanager maven file to your pom file and update your project. It works great.

Thanks. Mohamed Nashat.

0

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


All Articles