custom query
A repository query written out explicitly, usually with Spring Data's @Query annotation, instead of being derived from the method name.
In more detail
Custom queries make complex intent explicit and reviewable. JPQL, the Jakarta Persistence query language, looks like SQL but refers to entities and fields rather than tables and columns.
Example
@Query("select o from OrderEntity o where o.status = :status")Related terms
- 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.
- Spring Data JPA — A Spring project that generates repository implementations from interfaces, so declaring an interface is enough to get common database operations.
- SQL — The standard language for defining, querying and changing data in a relational database.
Taught in
- Spring Data Repositories — Modern Java: Virtual Threads & High-Throughput Services