Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data JPA 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;  
        } 
like image 962
james Avatar asked Feb 19 '14 04:02

james


People also ask

What is difference between JpaRepository and CrudRepository?

CrudRepository provides CRUD functions. PagingAndSortingRepository provides methods to do pagination and sort records. JpaRepository provides JPA related methods such as flushing the persistence context and delete records in a batch.

Which configuration in Spring Data JPA provides database connection details to the application?

Configuring the Datasource Bean Configure the database connection. We need to set the name of the JDBC driver class, the JDBC url, the username of database user, and the password of the database user.

What is @entity annotation in spring boot?

The @Entity annotation specifies that the class is an entity and is mapped to a database table. The @Table annotation specifies the name of the database table to be used for mapping.


1 Answers

It should be.

org.hibernate.jpa.HibernatePersistenceProvider

As the provider

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

like image 82
Koitoer Avatar answered Oct 11 '22 14:10

Koitoer