Consider sort order for unpaged Pageable in Querydsl.
We now apply sorting using Querydsl for Pageable that is sorted but not paged. Closes #3761
This commit is contained in:
@@ -108,12 +108,11 @@ public class Querydsl {
|
||||
Assert.notNull(pageable, "Pageable must not be null");
|
||||
Assert.notNull(query, "JPQLQuery must not be null");
|
||||
|
||||
if (pageable.isUnpaged()) {
|
||||
return query;
|
||||
}
|
||||
if (pageable.isPaged()) {
|
||||
|
||||
query.offset(pageable.getOffset());
|
||||
query.limit(pageable.getPageSize());
|
||||
query.offset(pageable.getOffset());
|
||||
query.limit(pageable.getPageSize());
|
||||
}
|
||||
|
||||
return applySorting(pageable.getSort(), query);
|
||||
}
|
||||
|
||||
@@ -723,7 +723,6 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
* @param pageable must not be {@literal null}.
|
||||
*/
|
||||
protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pageable) {
|
||||
|
||||
return getQuery(spec, getDomainClass(), pageable.getSort());
|
||||
}
|
||||
|
||||
@@ -736,7 +735,6 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
*/
|
||||
protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec, Class<S> domainClass,
|
||||
Pageable pageable) {
|
||||
|
||||
return getQuery(spec, domainClass, pageable.getSort());
|
||||
}
|
||||
|
||||
|
||||
@@ -282,9 +282,15 @@ class QuerydslJpaPredicateExecutorUnitTests {
|
||||
assertThat(users).contains(carter, dave, oliver);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-585
|
||||
@Test // DATAJPA-585, 3761
|
||||
void worksWithUnpagedPageable() {
|
||||
|
||||
assertThat(predicateExecutor.findAll(user.dateOfBirth.isNull(), Pageable.unpaged()).getContent()).hasSize(3);
|
||||
|
||||
Page<User> users = predicateExecutor.findAll(user.dateOfBirth.isNull(),
|
||||
Pageable.unpaged(Sort.by(Direction.ASC, "firstname")));
|
||||
|
||||
assertThat(users).containsExactly(carter, dave, oliver);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-912
|
||||
|
||||
Reference in New Issue
Block a user