Spring parses the name and writes the JPQL, so simple finders need no query at all.
interface OrderRepository extends JpaRepository<Order, Long> {
List<Order> findByStatus(Status status);
List<Order> findByStatusAndTotalGreaterThan(Status status, BigDecimal min);
Optional<Order> findFirstByCustomerIdOrderByPlacedAtDesc(Long customerId);
long countByStatus(Status status);
}
findByStatusAndTotalGreaterThan generates:
select o from Order o where o.status = ?1 and o.total > ?2
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11