Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.0.BUILD-SNAPSHOT</version>
<version>1.8.0.DATAREDIS-551-SNAPSHOT</version>

<name>Spring Data Redis</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* Redis specific {@link QueryEngine} implementation.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.7
*/
class RedisQueryEngine extends QueryEngine<RedisKeyValueAdapter, RedisOperationChain, Comparator<?>> {
Expand Down Expand Up @@ -156,6 +157,10 @@ public Collection<?> execute(final RedisOperationChain criteria, Comparator<?> s
@Override
public long count(final RedisOperationChain criteria, final Serializable keyspace) {

if(criteria == null) {
return this.getAdapter().count(keyspace);
}

return this.getAdapter().execute(new RedisCallback<Long>() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ public void shouldApplyPageableCorrectlyWhenUsingFindAll() {
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
*/
Expand Down Expand Up @@ -317,6 +335,8 @@ public static interface PersonRepository extends PagingAndSortingRepository<Pers
List<Person> findTop2By();

List<Person> findTop2ByLastname(String lastname);

Page<Person> findBy(Pageable page);
}

/**
Expand Down