0

I want to retrieve a Page of message entity in the order of(from the bottom of the table to the top). The default format of springjpa is from the top of the table to the bottom. How can i achieve this ?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Thanus
  • 411
  • 2
  • 8
  • 21
  • What about something like this? [How to use OrderBy with findAll in Spring Data](https://stackoverflow.com/questions/25486583/how-to-use-orderby-with-findall-in-spring-data) – Peteef Jun 01 '18 at 23:41
  • @Peteef it doesnt work in my case, because i am using page instead of a List. so what would do is order the content in the page by ID – Thanus Jun 01 '18 at 23:58

1 Answers1

0

Since you already pass in a Pageable you can use that to specify the sort order.

PageRequest.of(page, size, Sort.by(new Order(DESC, "id")))
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348