Spring JPA自定义查询与WHERE条件中的参数组合? [英] Spring JPA custom query with combination of parameters in WHERE condition?

查看:712
本文介绍了Spring JPA自定义查询与WHERE条件中的参数组合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用至少三个参数之一的Spring Data中编写JPA查询?

How to write JPA query in Spring Data that uses at least one of three parameters?

我有以下三个参数:

  1. 编号(PK)
  2. 名称
  3. 姓氏

客户端必须提供这三个参数中的至少一个,我想通过这些非空参数来查找用户.

Client must supply at least one of these three parameters and I want to find user by these not-empty parameters.

是否可以在我的存储库中创建此类自定义查询,还是必须为WHERE条件的所有可能组合创建自定义查询?

Is it possible to create such custom query to my repository or do I have to create custom queries for all possible combination of WHERE conditions?

推荐答案

非常感谢您的答复...当我阅读Spring时,它不像其他框架那么灵活...例如,我尝试了一些node js api框架,它更简单,更灵活..您对此有何看法?

thanks a lot for the reply ... as i read Spring is not easy flexible as other framework... for i.e i tried some node js api framework and it is easier and more flexible .. what do you think about this ?

这篇关于Spring JPA自定义查询与WHERE条件中的参数组合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆