Barium Scoorge
Barium Scoorge

Reputation: 2028

Spring MVC Repository and Hibernate

Following Spring docs, I've created a maven project with the following dependencies :

<dependencies>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.3-1102-jdbc41</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

I'd like to know if Repository data abstraction "goes through" hibernate or not.

Upvotes: 0

Views: 171

Answers (2)

matsev
matsev

Reputation: 33779

If you are unsure which dependencies your project have, you can use the maven-dependency-plugin. Specifically, you can use dependency:tree to get a hierarchal tree view of all dependencies and their transitive dependencies (or dependency:list to get a plain list), e.g.

$ mvn dependency:tree

And to answer your question: Yes, spring-boot-starter-data-jpa does depend on Hibernate:

[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.2.0.RELEASE:compile
[INFO] |  +- 
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:4.3.7.Final:compile
[INFO] |  |  +- 
[INFO] |  |  +- org.hibernate:hibernate-core:jar:4.3.7.Final:compile
[INFO] |  |  |  +- 
[INFO] |  |  +- 
[INFO] |  |  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  +- 

Upvotes: 1

Ori Dar
Ori Dar

Reputation: 19020

From the reference documentation:

28.3 JPA and ‘Spring Data’

The Java Persistence API is a standard technology that allows you to ‘map’ objects to relational databases. The spring-boot-starter-data-jpa POM provides a quick way to get started. It provides the following key dependencies:

Hibernate — One of the most popular JPA implementations.

Spring Data JPA — Makes it easy to easily implement JPA-based repositories.

Spring ORMs — Core ORM support from the Spring Framework.

So the answer is "Yes".

BTW, Spring will create and bootstrap automatically an EntityManagerFactory and DataSource beans by declaring a spring-boot-starter-data-jpa dependency.

Upvotes: 1

Related Questions