选择实体包含列表的位置,该列表就是另一个列表的子集 [英] Selecting where an entity contains a list thats a subset of another list
问题描述
我正在编写JPQL查询,并且遇到以下情况.我有一个Question实体,其中包含标签列表.我想选择所有包含给定标签列表的问题.我如何使用JPA做到这一点?
I am writing a JPQL query and i have the following scenario. I have a Question entity which contains a list of Tags. I would like to select all Questions that contains a given List of tags. How do i do this with JPA?
我想做类似SELECT x FROM Question x WHERE x.tags'contain all':tags
I would like to do something like SELECT x FROM Question x WHERE x.tags 'contains all' :tags
推荐答案
[这将搜索ANY并非ALL;请参考其他正确答案.]
[This searches for ANY not ALL; please refer other correct answers.]
您可以将列表设置为参数.
You can set list as a parameter.
SELECT x FROM Question x WHERE x.tags IN :tags
也请尝试使用(:tags),因为这取决于您使用的JPA实现.
Also try using (:tags), as it depends on the JPA implementation you are using.
这篇关于选择实体包含列表的位置,该列表就是另一个列表的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!