Card 01/ 06
All 6 cards
ConceptDifficulty: Intermediate1 min
CrudRepository vs JpaRepository
interface RideRepository extends JpaRepository<RideEntity, Long> {} — no method bodies, and the interface already has save, findById, findAll, delete and more, implemented for you.
CrudRepository is the base: the create-read-update-delete methods and nothing else. JpaRepository extends it and adds what a JPA-backed application usually wants beyond basic CRUD — pagination through PagingAndSortingRepository, and batch operations like flush() and saveAllAndFlush() that talk to the persistence context directly.
Extend CrudRepository when basic CRUD is genuinely all a repository needs. Extend JpaRepository — the far more common choice in a JPA-backed application — the moment pagination or explicit flushing enters the picture.