Spring Custom Query with pageable

前端 未结 6 751
自闭症患者
自闭症患者 2020-12-30 07:29

I want to to implement pagination in spring application.I know using repository we can implement pagination but we can not write our own query for data retrieve there are li

6条回答
  •  自闭症患者
    2020-12-30 08:05

    By extending Spring Data PagingAndSortingRepository interface you can get some common methods such as save, find, findAll and delete and also you can add your own custom queries:

    public interface Repository extends PagingAndSortingRepository {
    
        // Common method
        Page findAll(Pageable pageable);
    
        // Custom query based on Spring Data naming convention
        Page findByNameOrDescription(String name, String description, Pageable pageable);
    
    }
    

提交回复
热议问题