Spring data required hibernate or not - spring

I have one doubt about implementation of spring data, have basic knowledge about spring data.
I understand JPA and Hibernate, how it work. Hibernate provide the implementation for JPA.
My questions, Can we work alone with Spring data to persist data in mysql or we need some provider like hibernate or toplink etc for midsize application

The structure is as follows:
Spring Data JPA
|
JPA
|
Hibernate
You need Hibernate as an JPA implementation, but from your perspective you should only see Spring Data JPA.
When designing your entities if you make sure that you use only annotations from the javax.persistence package you will not depend on one concrete JPA implementation (in this case Hibernate) but theoretically you could swap Hibernate for EclipseLink or something else.

Related

spring data jpa and jpa implementation

As we know that, spring data jpa just adds extra layer on jpa provider. Spring community provides some spring data jpa starter example here
https://spring.io/guides/gs/accessing-data-jpa/#initial
I didn't see any jpa provider used in this example, how could that happen?
Thanks
Spring boot provide jpa
For example, if you want to use Spring and JPA for database access, it is sufficient if you include spring-boot-starter-data-jpa dependency in your project.

Query relational database with Spring Data JPA and Hibernate

I am new to Spring and Hibernate. I have a project using Spring, Hibernate and PostgreSQL. I know that I can query the database using Spring Data JPA or Hibernate, but I don't know what the benefits and disadvantages of each approach. I also know that in the background, Spring Data JPA will call Hibernate. So what is the best way I should use to query the database to get the best performance, Spring Data JPA or Hibernate or depending on the specific usage situation. Thanks very much
I think it is based on the requirements of your project.
You can find more answers to this question at StackOverflow.

Is Spring Data JPA a JPA implementation?

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?
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.

HikariCP and Spring JPA

I was reading the documentation of Spring Boot and HikariCP and would like to integrate it to my SB app, but I got a little confused when it comes to Hikari and JPA.
I'm currently using Spring Data (spring-boot-starter-data-jpa) and my questions are: can I use HikariCP when using JPA? will it interfere on the way Hibernate connects to database? should I do some other configuration to make Hibernate using HikariCP? it wasn't really clear on documentations
There is no issue with using JPA and HikariCP together. Depending on which JPA implementation you want to use you can look around a bit more, but generally Hibernate and EclipseLink are supported. For example here is an example using the exact set of technologies you described:
HikariCP + JPA + spring-data

Spring roo and jOOQ

jOOQ should be an alternative to standard JPA. Is there any way to use it in Roo as JPA provider? Is it even possible?
The reason for this: We have Oracle database and jOOQ has quick and easy set up for connection to that database. On the other hand, Roo is very usefull tool but lacks on setting up Oracle database connection.
jOOQ doesn't implement JPA. It just happens to support a few JPA annotations, which is far from actually implementing JPA. In other words, no you cannot use jOOQ as a JPA provider in Spring Roo

Resources