Question

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;  
        } 
Was it helpful?

Solution

It should be.

org.hibernate.jpa.HibernatePersistenceProvider

As the provider

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

OTHER TIPS

Your code is perfectly alright. You don't need any alternative solutions. The issue is because of you missed the hibernate entity manager .jar library [or hibernate-entitymanager maven dependency if your using maven as your project builder]. Add hibernate-entitymanager maven dependency inside your pom file and update your project. It's work fine.

Thank you. Mohamed Nashath.

I also had this problem. I've fixed it by adding following dependency to pom.xml:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.0.2.Final</version>
</dependency>

plus

import org.hibernate.ejb.HibernatePersistence;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top