Skip to main content

Spring Data JPA: Repository Interfaces, JpaRepository, Derived Queries, @Query and Native Queries

Learn Spring Data JPA: Repository Interfaces, JpaRepository, Derived Queries, @Query and Native Queries (Phase 10 · Hibernate with Spring Boot (Essential), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Repository interfaces • Spring Data JPA removes DAO boilerplate: declare an interface and Spring generates the implementation (a proxy backed by SimpleJpaRepository ) using Hibernate/JPA. • Hierarchy: Repository (marker) → CrudRepository ( save , findById , findAll , deleteById , existsById , count ) → ListCrudRepository / PagingAndSortingRepository → JpaRepository (adds flush , saveAndFlush , saveAll , deleteAllInBatch , getReferenceById , findAll(Sort) , findAll(Pageable) ) and JpaSpecificationExecutor for Specifications. • Enable with Spring Boot (auto-configured) or @EnableJpaRepositories...

More lessons in Phase 10 · Hibernate with Spring Boot (Essential)