In Spring Data, can I turn off query generation from method names?
Given the interface
public interface UserRepository extends Repository<User, Long> { List<User> findByEmailAddressAndLastname(String emailAddress, String lastname); }
I would like Spring to provide an error indicating that query generation from method names is disabled, please use the @Query annotation explicitly.
public interface UserRepository extends Repository<User, Long> { @Query("select u from User u where u.emailAddress = ?1 and u.lastname = ?2") List<User> findByEmailAddressAndLastname(String emailAddress, String lastname); }
I want to disable automatic query creation, because, in my opinion, itβs easier to read the request and know what is happening, rather than reading the method name and translating into what the Spring request will generate also in a large team with a large number of developers, some of which maybe not familiar with Spring @Query data, more readable?
How to disable query creation from method names in Spring JPA?
java spring spring-data spring-data-jpa
ams
source share