You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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";
The text was updated successfully, but these errors were encountered:
My apologies, it was remiss of me to omit the version info. I am using Spring Boot version 3.3.5 and the problem manifests through spring-boot-starter-data-jpa. Sounds like I should upgrade to 3.4 once it's released. In the meantime I have a workaround which is to call the findAll(Sort) method when an unsorted Pageable is passed.
(BTW before raising this issue I did search the spring-data-commons project for any issues relating to PagingAndSortingRepository but didn't find any of relevance.)
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:
The text was updated successfully, but these errors were encountered: