Card 06/ 06

RecapDifficulty: Advanced1 min

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.

What the topic established, and which card it was on
The ideaWhere
A repository interface gets CRUD for free; JpaRepository adds paging, sorting and flushingSpring Data Repositories: CrudRepository and JpaRepository
A method name alone can build a query, checked at startupSpring Data Example: A Query Derived From a Method Name
@Query writes JPQL for joins between entities with no mapped relationshipSpring Data Example: @Query for a Join a Method Name Cannot Express
save() on an entity with an id updates that rowSpring 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.