EclipseLink INTERSECT 过滤掉两个集合是否有共同元素
有人可以帮忙吗?
实体A具有一组枚举的字段。
方法采用一组枚举。
任务 - 如果A.Field具有与传递的枚举集共有1个或更多元素,则过滤掉值。 我试图通过Intersect实现它,但结果尚未实现。
工作解决方案 - 不是成员,但只能用于1个参数...可以使用()实现,但我相信这不是一个好练习...
could anybody help?
Entity A has a field with set of enums.
Method takes a set of enums.
Task - filter out values if A.field has 1 or more elements in common with passed set of enums.
I was trying to achieve it via INTERSECT, but the result wasn't achieved.
Working solution - NOT MEMBER OF, but it could be used only for 1 parameter... possible to implement with for(), but I am sure that it isn't a good practice...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有直接的方法可以将一个集合与JPA中的另一个集合进行比较。
围绕该问题的解决方案虽然涉及次数,但JPA将采取什么措施评估您的条款成员。一个子查询使您可以查看集合中的单个值并将其与另一个值进行比较,并将其使用导致您的主要查询。按照:
我不是DBA,但是如果有人抱怨这是效率低下的,那么还有许多其他表达方式,可能存在:
There is no direct way to compare one collection to another in JPA.
Solutions around the issue though involve subqueries, very similar what JPA will do to evaluate your MEMBER OF clause. A sub-query lets you look at individual values in a collection and compare it to the other, and use that result in your main query. Something along the lines of:
I'm not a DBA, but if one complains this is inefficient, there many other ways of being expressed, possibly with exists: