0

I was trying out a sample project spring-data with hibernate as the JPA provider.(from this link:

[https://github.com/Fruzenshtein/spr-data][1]).

It uses Hibernate-entitymanager 4.2.1.Final. After upgrading Hibernate to 4.3.10, I am getting problems in WebAppConfig.java (Java config for JPA). It complains on:

entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);

It says:

The type javax.persistence.spi.PersistenceProvider cannot be resolved

Is this not supported in the newer version?

Update:

OK basically, the dependencies were not downloaded propeprly for the newer version and so I was getting an error. The error is gone now after downloading the dependencies correctly. However, I see that the HibernatePersistence class is deprectated now. What is the reason for this and what is the alternative for this now?

Here is the code snippet:

    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactoryBean.setDataSource(dataSource());
        entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
        entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));

    entityManagerFactoryBean.setJpaProperties(hibProperties());
user1892775
  • 2,001
  • 6
  • 37
  • 58

0 Answers0