Query Methods
Explore derived and custom query methods of the Spring Data repositories.
We'll cover the following...
We'll cover the following...
Query methods in Spring Data
Every repository method, when invoked, usually runs a query on the underlying database. Let’s look at different ways of running a data access query on the database using Spring Data repositories.
Derived query methods
Spring Data comes with a query builder mechanism that helps us generate derived query methods using keywords, like FirstBy, OrderBy, and Distinct acting as the subject and And, Or, and OrderBy as the predicate, to set conditions on the properties of a POJO.
Explanation:
- Line 16: We declare a method to fetch and return a list of customer objects that match the first name passed through an argument.
- Line 18: We define a query method to return the