Pagination in Spring Data JPA (limit and offset)

后端 未结 7 1053
眼角桃花
眼角桃花 2020-12-02 08:54

I want the user to be able to specify the limit (the size of the amount returned) and offset (the first record returned / index returned) in my query method.

Here a

7条回答
  •  长情又很酷
    2020-12-02 09:18

    Suppose you are filtering and soring and paging at same time Below @Query will help you

        @Query(value = "SELECT * FROM table  WHERE firstname= ?1  or lastname= ?2 or age= ?3 or city= ?4 or "
            + " ORDER BY date DESC OFFSET ?8 ROWS FETCH NEXT ?9 ROWS ONLY" , nativeQuery = true)
    List filterJobVacancyByParams(final String firstname, final String lastname,
            final String age, final float city,int offset, int limit);
    

提交回复
热议问题