Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Spring Data JPA a JPA implementation?

Tags:

I am trying to "really" understand Spring Framework. I have got some fair understanding of Spring Core (DI), and Spring MVC.

For data part, I am now focussing on Spring Data JPA. As I understand, JPA is a standard specification, for which there are multiple implementations, Hibernate being the famous one.

Now, when I started Spring Data JPA, I was under the impression that Spring Data JPA is an independent implementation of JPA specification. It turned out that I am wrong.

If I understood correctly, Spring Data JPA is an abstraction layer provided by Spring, which internally uses other JPA provider (Example Hibernate), so typically it is like this:

Application ---> Spring Data JPA --> Hiberate --> JDBC ----> DB

Is my understanding correct? If so isn't Spring Data JPA misleading? It is NOT a JPA provider in itself, it is just an abstraction layer, which works on top of other JPA provider.

I am not sure if I really understand Spring framework or it is a complex framework altogether?

Can anyone please help me understand it?

like image 446
CuriousMind Avatar asked Apr 28 '16 16:04

CuriousMind


People also ask

Is JPA and Spring data JPA same?

Spring data jpa- it is same like jpa means we can describe in below way. Spring Data Jpa is jpa data abstraction access which means it likes a jpa but it add some extra functionality, Without jpa we can not implement the spring data jpa.

What is JPA and Spring data JPA?

Spring Data JPA API provides JpaTemplate class to integrate spring application with JPA. JPA (Java Persistent API) is the sun specification for persisting objects in the enterprise application. It is currently used as the replacement for complex entity beans.

What are different JPA implementations?

The JPA, short for Java Persistence API, is part of the Java EE 5 specification and has been implemented by Hibernate, TopLink, EclipseLink, OpenJPA, and a number of other object-relational mapping (ORM) frameworks.

What is the default implementation of JPA?

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.


1 Answers

I don't think it's misnamed (disclaimer: I am the project lead). All Spring Data projects list the store or API they're based on in their name. Spring Data JPA is basically Spring Data for JPA, just like Spring Data MongoDB is Spring Data for MongoDB, just like Spring Batch is Spring for batch applications, Spring Integration is Spring for integration projects.

Do correct your dependency graph for JPA:

Application -> Spring Data JPA -> JPA <- Hibernate -> JDBC -> DataSource  -> — uses <- — implements 

The same for MongoDB:

Application -> Spring Data MongoDB -> MongoDB Java driver -> MongoDB 

etc. I'd still be interested where exactly you got the impression that Spring Data JPA is an implementation of JPA as neither the project page nor the reference documentation state that anywhere. In fact, especially the project page is very explicit about what functionality the project provides. Also, it might help to study the description of the umbrella project, which tries to set some fundamental context for all the modules contained in it.

like image 95
Oliver Drotbohm Avatar answered Oct 20 '22 20:10

Oliver Drotbohm