Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (20.3k points)

What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?

When I see the examples on the web, I see them there used kind of interchangeably. What is the difference between them? Why would you want to use one over the other?

1 Answer

0 votes
by (119k points)

In short, the following are the differences between CrudRepository, PagingAndSortingRepository, and JpaRepository:

  • CrudRepository: provides CRUD (create, read, update and delete) functions
  • PagingAndSortingRepository: provides additional methods to do pagination and sort records
  • JpaRepository: provides some more functionality that are JPA related methods such as flushing the persistence context and delete records in a batch

If you want to learn Java from the top experts, then check out this Java Certification program by Intellipaat.

Browse Categories

...