Card 06/ 06
Recap: Repositories With Spring Data
Base interfaces, derived queries, @Query, and the update hidden inside save.
Spring Data repositories come down to the four ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
A repository interface gets CRUD for free; JpaRepository adds paging, sorting and flushing | Spring Data Repositories: CrudRepository and JpaRepository |
| A method name alone can build a query, checked at startup | Spring Data Example: A Query Derived From a Method Name |
@Query writes JPQL for joins between entities with no mapped relationship | Spring Data Example: @Query for a Join a Method Name Cannot Express |
save() on an entity with an id updates that row | Spring Data save(): Updating an Existing Row Instead of Inserting |
Between them they cover most data access in a Boot application: inherit the basics, derive the simple queries, and write JPQL only for the rest.
← → move through sections and cards