Spring Data JPA应用排序,分页以及where子句 [英] Spring Data JPA apply sorting, pagination along with a where clause
本文介绍了Spring Data JPA应用排序,分页以及where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Spring JPA并使用此处所述的排序和分页 -
I am currently Using Spring JPA and utilizing the Sorting and Pagination as described here -
如何通过Spring数据查询数据JPA by sort和pageable都是开箱即用的?
现在我的问题是如何在此处应用'where'子句?
Now my question is how do I apply a 'where' clause to this?
EG
where PRODUCT_NAME='abc';
推荐答案
只需在存储库界面中创建一个查询方法。
Just create a query method in your repository interface for this.
查看文档,这里。
使用paging和where子句添加查询方法。
Add a query method with paging and where clause.
Page<User> findByLastname(String lastname, Pageable pageable);
因此,您可以通过属性lastname找到User并配置分页设置。
So you can find User by a property "lastname" and configure Paging settings.
这篇关于Spring Data JPA应用排序,分页以及where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文