JDBC, JPA, Hibernate, JPARepository, PagingAndSortingRepository, CrudRepository
Short descriptions of JDBC, JPA, Hibernate, JPARepository, PagingAndSortingRepository and CrudRepository to give an idea where to use which
JDBC — JPA — Hibernate
JDBC (Java Database Connectivity) is an interface that communicate with a database. It’s the common API that our application code uses to communicate with the database.
JPA (Java Persistence API) is a Java standard that allows us to bind Java objects to records in a relational database (ORM — Object Relationship Mapping) by allowing to retrieve, store, update, and delete data in a relational database using these objects.
JPA serves as a layer of abstraction that hides the low-level JDBC calls from the developer, making database programming considerably easier.
Hibernate is an open-source, light-weight Java ORM framework. It is an implementation of JPA.
JPARepository — PagingAndSortingRepository — CrudRepository
There is a fine definition and a table for comparison here.
As an extra point, querying methods return List instead of Iterable in JpaRepository.
JpaRepository contains the full API of CrudRepository and PagingAndSortingRepository.
JpaRepository Interface (spring-data-jpa:2.5.6):
PagingAndSortingRepository Interface (spring-data-commons:2.5.6):
CrudRepository Interface (spring-data-commons:2.5.6):
There are also store-specific interfaces which eventually tighten the coupling when used so be careful choosing.
References:
https://www.tutorialspoint.com/difference-between-crudrepository-and-jparepository-in-java
https://www.baeldung.com/spring-data-repositories
https://stackoverflow.com/questions/40382741/what-exactly-is-the-difference-between-jparepository-and-crudrepository-using-sp
https://stackoverflow.com/questions/14014086/what-is-difference-between-crudrepository-and-jparepository-interfaces-in-spring/20784007#20784007
https://www.baeldung.com/jpa-vs-jdbc
https://www.geeksforgeeks.org/difference-between-jdbc-and-hibernate-in-java/
Happy Coding!