Spring Data JPA
A Spring project that generates repository implementations from interfaces, so declaring an interface is enough to get common database operations.
In more detail
Extending JpaRepository<Entity, IdType> provides save, findById, findAll and more. Methods named by convention, such as findByStatus, become queries automatically, and @Query states more complex ones. Keep repository interfaces small so controllers never depend on database vocabulary.
Example
public interface OrderRepository extends JpaRepository<OrderEntity, String> { List<OrderEntity> findByStatus(String status); }Related terms
- repository pattern — Putting all the code that reads and writes one kind of data behind a single object, so the rest of the app never talks to the database directly.
- derived query method — A Spring Data repository method whose query is worked out from its name, such as findByStatus meaning select entities whose status equals the argument.
- custom query — A repository query written out explicitly, usually with Spring Data's @Query annotation, instead of being derived from the method name.
- JPA — The Jakarta standard for mapping Java objects to relational database tables and managing them, implemented by libraries such as Hibernate.
Taught in
- Spring Data Repositories — Modern Java: Virtual Threads & High-Throughput Services
- Tying It All Together — Modern Java: Virtual Threads & High-Throughput Services