-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply
Description
QuerydslPredicateExecutor provides a method Page<T> findAll(Predicate predicate, Pageable pageable);
You can pass Pageable.unpaged() to get all rows in single page, in this case result not sorted.
If you write custom implementation of unpaged() that has some sort and pass it to findAll, this doesnt work because of this code:
https://github.com/spring-projects/spring-data-jpa/blob/main/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java#L117
`
if (pageable.isUnpaged()) {
return query;
}
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
return applySorting(pageable.getSort(), query);
`
Sorting applied after isUnpaged() check.
We can change code to:
`
if (pageable.isPaged()) {
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
}
return applySorting(pageable.getSort(), query);
`
And this code allows sorting of unpaged queries.
Linked with #3761
danilofd and andrey-nakin
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply