How to query data out of the box using Spring data JPA by both Sort and Pageable?

后端 未结 6 1658
别那么骄傲
别那么骄傲 2020-12-12 12:50

I am trying Spring data JPA in my project. I want to know if there is an out-of-the-box API to query data, by both Sort and Pageable. Of course, I

6条回答
  •  情书的邮戳
    2020-12-12 13:41

     public List getAllData(Pageable pageable){
           List models= new ArrayList<>();
           modelRepository.findAllByOrderByIdDesc(pageable).forEach(models::add);
           return models;
       }
    

提交回复
热议问题