Skip to content

PagingAndSortingRepository.findAll(Pageable) ignores an unpaged Pageable with a sorted Sort #3676

Closed as not planned
@demonfiddler

Description

@demonfiddler

Passing an unpaged Pageable containing a sorted Sort to the PagingAndSortingRepository.findAll(Pageable) method ignores the Pageable's Sort, generating an SQL SELECT statement that is missing the requisite ORDER BY clause. The following code fragment illustrates the problem:

List<Order> orders = List.of(Order.asc("sortProperty"));
Sort sort = Sort.by(orders);
Pageable pageable = Pageable.unpaged(sort);
ListPagingAndSortingRepository<T, ID> repository = ...;
Page<T> unsortedPage = repository.findAll(pageable);
List<T> sortedContent = repository.findAll(sort);
assert unsortedPage.getContent().equals(sortedContent) : "The findAll(Pageable) overload does not sort the content";

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions