Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whether Spring boot Data JPA uses hibernate internally for it's implementation?

I am working to set up an existing project, I found the following dependency in pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

but there is no any dependency for hibernate so how to check whether a project using hibernate or not.

And Also I found JpaConfiguration class which contains following code.

@Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactoryBean.setDataSource(dataSource);

        String entities = ClassUtils.getPackageName(ArkonnApplication.class);
        String converters = ClassUtils.getPackageName(Jsr310JpaConverters.class);
        entityManagerFactoryBean.setPackagesToScan(new String[]{entities, converters});

        entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

        Properties jpaProperties = new Properties();
        jpaProperties.put("hibernate.dialect", dialect);
        jpaProperties.put("hibernate.hbm2ddl.auto", hbm2ddlAuto);
        jpaProperties.put("hibernate.show_sql", showSql);
        jpaProperties.put("hibernate.format_sql", formatSql);
        jpaProperties.put("hibernate.use_sql_comments", useSqlComments);
        entityManagerFactoryBean.setJpaProperties(jpaProperties);

        return entityManagerFactoryBean;
    }

if this project is using the hibernate then why there is no any dependency or configuration for it.

1) Is Spirng boot Data JPA comes with default Hibernate configuration ?.

2) If yes, how spring boot Data JPA work internally with Hibernate.(any reference link)

like image 777
Sachin Jagtap Avatar asked Dec 05 '18 07:12

Sachin Jagtap


People also ask

Is Spring data JPA internally uses Hibernate?

This is the type of code Spring Data JPA helps to avoid. Spring Data JPA is really a set of dependencies that makes it easier to work with a JPA provider. Hibernate is one of several JPA providers. This means you can use Spring Data JPA without using Hibernate (if you really wanted to).

Does Spring data JPA use Hibernate by default?

JPA is an interface and Hibernate is the implementation. By default Spring uses Hibernate as the default JPA vendor. If you prefer, you can use any other reference implementation e.g. EclipseLink for the Java Persistence in your Spring project.

Does spring boot starter data JPA include Hibernate?

spring-boot-starter-data-jpa (required) : It includes spring data, hibernate, HikariCP, JPA API, JPA Implementation (default is hibernate), JDBC and other required libraries.

Is Hibernate part of Spring JPA?

Hibernate is a JPA implementation, while Spring Data JPA is a JPA data access abstraction. Spring Data JPA cannot work without a JPA provider. Spring Data offers a solution to the DDD Repository pattern or the legacy GenericDao custom implementations.


1 Answers

JPA is an interface and Hibernate is the implementation. By default, Spring uses Hibernate as the default JPA vendor. you can see hibernate related dependency in dependency hierarchy under the pom.xml, this will resolve all dependencies of your project.

like image 76
Rohit Mewada Avatar answered Oct 07 '22 14:10

Rohit Mewada