Hibernate 限制(和/或)
关于限制的小问题。
我有这样的查询:
Where A in(1,6) and (B not like 'Value%' or B not like 'ValueII%')
问题是字段 B 不包含固定值,可以是一个或多个。
请 (N)Hibernate 专家帮助我解决这个问题,我找不到可行的解决方案。非常感谢任何帮助!
small questions about Restrictions.
i have query like this :
Where A in(1,6) and (B not like 'Value%' or B not like 'ValueII%')
the problem is the field B not contains a fixed value, can be one or more.
Please, (N)Hibernate experts - help me with this, I cant find a working solution. Any help is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用析取来处理 OR 情况,如下所示:
如果您需要在 for 循环中处理析取条件(根据您的后续操作),您可以使用如下代码:
话虽这么说,我认为可能有一个你的逻辑有缺陷。如果您测试这些值“不匹配一个模式或不匹配另一模式”,则条件将始终评估为 true(除非模式相同)。您确定要在这里使用 OR 吗?
You can use disjunctions to handle the OR cases, as such:
If you need to handle the disjunction conditions in a for loop (per your follow-up), you can use code like this:
That being said, I think there may be a flaw in your logic. If you are testing these values to "not match one pattern OR not match another pattern", then the condition will always evaluate to true (unless the patterns are the same). Are you sure you want to be using ORs here?
问题是我不知道到底有多少限制,并且我需要在析取中使用 FOR 。
类似这样的:
谢谢你的帮助
the problem is that I don't know exact how many restrictions i have and i need to use FOR in disjunction.
Something like that:
thanks for you help