You can specify the query-lookup-strategy
on the repositories
tag in the configuration.
<repositories query-lookup-strategy="use-declared-query"/>
See the documentation
User.java
@Entity
@NamedQuery(name="User.findByEmailAddressAndLastName",
query="select u from User u where u.emailAddress = ?1 and u.lastname = ?2")
public User{
}
UserRepository.java
public interface UserRepository extends Repository<User, Long> {
List<User> findByEmailAddressAndLastname(String emailAddress, String lastname);
}