DATAJPA-23 - Fixed query building for IsNull and IsNotNull.
Use the actually accessed path instead of the root object. Added test cases to verify behaviour.
This commit is contained in:
@@ -759,6 +759,31 @@ public class UserRepositoryTests {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void executesFindByNotNullLastnameCorrectly() throws Exception {
|
||||
|
||||
flushTestUsers();
|
||||
List<User> result = repository.findByLastnameNotNull();
|
||||
|
||||
assertThat(result.size(), is(3));
|
||||
assertThat(result, hasItems(firstUser, secondUser, thirdUser));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void executesFindByNullLastnameCorrectly() throws Exception {
|
||||
|
||||
flushTestUsers();
|
||||
User forthUser =
|
||||
repository.save(new User("Foo", null, "email@address.com"));
|
||||
|
||||
List<User> result = repository.findByLastnameNull();
|
||||
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result, hasItems(forthUser));
|
||||
}
|
||||
|
||||
|
||||
private Page<User> executeSpecWithSort(Sort sort) {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
@@ -190,4 +190,10 @@ public interface UserRepository extends JpaRepository<User, Integer>,
|
||||
|
||||
|
||||
List<User> findByColleaguesLastname(String lastname);
|
||||
|
||||
|
||||
List<User> findByLastnameNotNull();
|
||||
|
||||
|
||||
List<User> findByLastnameNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user