Spring Data implements the interface for you from the selected columns.
interface OrderView {
Long getId();
String getReference();
BigDecimal getTotal();
}
interface OrderRepository extends JpaRepository<Order, Long> {
List<OrderView> findByStatus(Status status);
}
Spring generates a proxy implementing OrderView,
and selects only id, reference and total.
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