I want to force add sorting parameter to Pageable, even if one is passed. @SortDefault(sort = {"id"})
works well, but only if sorting value is not passed. If is - this annotation is ignored.
How to add "sort by id" even if sorting by other fields is passed? The sorting by ID should be on last place.
Asked
Active
Viewed 406 times
0

B_Osipiuk
- 888
- 7
- 16
1 Answers
1
I found a little walkaround that works:
var pageableWithId = PageRequest.of(
pageable.getPageNumber(),
pageable.getPageSize(),
pageable.getSort().and(Sort.by("id")));

B_Osipiuk
- 888
- 7
- 16