How to use OrderBy with findAll in Spring Data

前端 未结 7 1018
无人共我
无人共我 2020-12-02 04:25

I am using spring data and my DAO looks like

public interface StudentDAO extends JpaRepository {
    public findAllOrderByIdAsc         


        
7条回答
  •  借酒劲吻你
    2020-12-02 04:30

    Simple way:

    repository.findAll(Sort.by(Sort.Direction.DESC, "colName"));
    

    Source: https://www.baeldung.com/spring-data-sorting

提交回复
热议问题