问题描述
我正在尝试迁移应用程序.我正在从 Hibernate 到 Spring Data Jpa 工作.
I am trying to migrate the application. I am working on from Hibernate to Spring Data Jpa.
虽然 spring data jpa 提供了简单的查询构建方法,但我坚持创建同时使用 And 和 Or 运算符 的查询方法.
Though spring data jpa offers simple methods for query building, I am stuck up in creating query method that uses both And and Or operator.
方法名 - findByPlan_PlanTypeInAndSetupStepIsNullOrStepupStepIs(...)
当它转换成查询时,前两个表达式被组合起来,它执行为[(exp1 and exp2) or (exp3)].
When it converts into the query, the first two expressions are combined and it executes as [(exp1 and exp2) or (exp3)].
而需要的是](exp1) and (exp2 or exp3)].
谁能告诉我这是否可以通过 Spring data jpa 实现?
Can anyone please let me know if this is achievable through Spring data jpa?
推荐答案
同意 Oliver 的方法名称冗长且不可读,但是为了论证,您可以通过使用等效性来达到预期的结果
Agree with Oliver on long and unreadable method names, but nevertheless and for the sake of argument, you can achieve desired result by using the equivalency
A / (B / C) <=> (A / B) / (A / C)
A and (B or C) <=> (A and B) or (A and C)
所以在你的情况下它应该看起来像这样:
So in your case it should look something like this:
findByPlan_PlanTypeInAndSetupStepIsNullOrPlan_PlanTypeInAndStepupStepIs(...)
这篇关于Spring data jpa - 如何通过方法名称组合多个And和Or的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)