23

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?

Oliver Drotbohm
  • 80,157
  • 18
  • 225
  • 211
CuriousMind
  • 8,301
  • 22
  • 65
  • 134
  • 5
    yes, its a misleading name. yes it is NOT a JPA provider. Yes it simply is an abstraction layer. Yes people often tag questions on here as JPA when they mean Spring Data JPA. And there are many other implementations of JPA that have their own advantages – Neil Stockton Apr 28 '16 at 16:54
  • 1
    Seems about right, except that the level of abstraction seems to me to be very high. [Spring Data JPA - Reference Documentation](http://docs.spring.io/spring-data/jpa/docs/current/reference/html/). – K.Nicholas Apr 28 '16 at 16:55
  • Thanks for your replies. I believe in essence Spring uses the "existing frameworks", not that it does any specification implementation? Am I correct? This is making me wonder how come Spring is a famous framework, when it is simply using the existing frameworks under the hood. – CuriousMind Apr 28 '16 at 16:58
  • 1
    @CuriousMind That's because Spring IS a framework (most people refer to the original framework, when they are saying "Spring"). But in the meantime Spring became a whole ecosystem consisting of the original frameworksand many other frameworks, abstractions etc. like Spring Data. – dunni Apr 28 '16 at 17:10
  • Thanks for your comments. I believe it is still a steep learning curve to understand this, and for a new comer it isn't that simple. – CuriousMind Apr 28 '16 at 17:13

1 Answers1

42

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.

Oliver Drotbohm
  • 80,157
  • 18
  • 225
  • 211
  • 4
    Thanks so much for your wonderful explanation, it clears the things. It was my personal interpretation that when they say "Spring Data JPA" it might be an implementation of JPA. Instead of keeping this doubt in mind and build knowledge on wrong assumed things, I decided to ask this question to seek clarification to my doubts/understanding. Thanks a lot! – CuriousMind Apr 28 '16 at 18:04
  • @OliverGierke, Hello Oliver … Could you please help me answering this question: https://stackoverflow.com/questions/50553782/spring-hibernate-transactional-is-not-working-in-spring-data-jpa-despite-being – securecurve May 27 '18 at 16:32
  • @OliverGierke .. Thanks! – securecurve May 27 '18 at 16:32