DATAJPA-92 - Added support for IgnoreCase keyword.
The query creation subsystem now supports using IgnoreCase when referencing String parameters, e.g.: findByUsernameIgnoreCase(String username); Both 'IgnoreCase' and 'IgnoringCase' are supported. If you'd like to entirely ignore cases for all String property references add 'AllIgnoreCase' or 'AllIgnoringCase' to the query method.
This commit is contained in:
@@ -155,4 +155,26 @@ public class UserRepositoryFinderTests {
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result.get(0), is(oliver));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsByLastnameIgnoringCase() throws Exception {
|
||||
List<User> result = userRepository.findByLastnameIgnoringCase("BeAUfoRd");
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result.get(0), is(carter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsByLastnameIgnoringCaseLike() throws Exception {
|
||||
List<User> result = userRepository.findByLastnameIgnoringCaseLike("BeAUfo%");
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result.get(0), is(carter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByLastnameAndFirstnameAllIgnoringCase() throws Exception {
|
||||
List<User> result = userRepository.findByLastnameAndFirstnameAllIgnoringCase("MaTTheWs","DaVe");
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result.get(0), is(dave));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -215,4 +215,15 @@ public interface UserRepository extends JpaRepository<User, Integer>,
|
||||
|
||||
|
||||
List<User> findBySpringDataNamedQuery(String lastname);
|
||||
|
||||
|
||||
List<User> findByLastnameIgnoringCase(String lastname);
|
||||
|
||||
|
||||
List<User> findByLastnameIgnoringCaseLike(String lastname);
|
||||
|
||||
|
||||
List<User> findByLastnameAndFirstnameAllIgnoringCase(String lastname,
|
||||
String firstname);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user