DATAREDIS-551 - Fix pageable query execution when derived criteria is empty.

We now make sure to count records without using criteria when derived criteria is empty. This allows usage of declared query methods using `Pageable` without criteria like `findBy(Pageable page)`.

Original Pull Request: #220
This commit is contained in:
Mark Paluch
2016-09-06 17:09:17 +02:00
committed by Christoph Strobl
parent a8462c597e
commit 5aef8c3b0b
2 changed files with 25 additions and 0 deletions

View File

@@ -222,6 +222,24 @@ public abstract class RedisRepositoryIntegrationTestBase {
assertThat(repo.findAll(firstPage.nextPageable()).getContent(), hasSize(1));
}
/**
* @see DATAREDIS-551
*/
@Test
public void shouldApplyPageableCorrectlyWhenUsingFindByWithoutCriteria() {
Person eddard = new Person("eddard", "stark");
Person robb = new Person("robb", "stark");
Person jon = new Person("jon", "snow");
repo.save(Arrays.asList(eddard, robb, jon));
Page<Person> firstPage = repo.findBy(new PageRequest(0, 2));
assertThat(firstPage.getContent(), hasSize(2));
assertThat(firstPage.getTotalElements(), is(equalTo(3L)));
assertThat(repo.findBy(firstPage.nextPageable()).getContent(), hasSize(1));
}
/**
* @see DATAREDIS-547
*/
@@ -317,6 +335,8 @@ public abstract class RedisRepositoryIntegrationTestBase {
List<Person> findTop2By();
List<Person> findTop2ByLastname(String lastname);
Page<Person> findBy(Pageable page);
}
/**