JPA query creation order by

后端 未结 4 1560
孤城傲影
孤城傲影 2021-02-18 22:07

I\'m trying to learn Spring on my own, and I\'m planning to do that by creating a blog web app. I already have the basic blog functionality working, which is a page to display b

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-18 22:26

    There is an extension to CrudRepository called PagingAndSortingRepository

     public interface PostRepository extends PagingAndSortingRepository {}
    

    Then just call .findAll(new Sort(Sort.Direction.DESC, "id")); instead of findAllOrderByIdDesc();

提交回复
热议问题