A custom repository operation adds a data-access action beyond the standard operations inherited from a Spring Data repository contract. section 14.3
In Spring Data JDBC, repository methods can:
- Use a method name such as findAccountsByName to retrieve matching accounts. section 14.3
- Use @Query to specify SQL explicitly, or combine it with @Modifying for an update. section 14.3
Account lookup
An AccountRepository extending CrudRepository can add findAccountsByName(String name). In a wallet application, a service can use this operation to find accounts while implementing a money transfer. section 14.3
Listing 14.5 Adding a repository operation to get all the accounts with a specified name
public interface AccountRepository
extends CrudRepository<Account, Long> {
List<Account> findAccountsByName(String name);
}See the repository declaration for a derived-name operation that finds accounts by name. section 14.3
