选择实体包含列表的位置,该列表是另一个列表的子集 [英] Selecting where an entity contains a list thats a subset of another list
问题描述
我正在编写一个 JPQL 查询,我有以下场景.我有一个包含标签列表的问题实体.我想选择包含给定标签列表的所有问题.我如何使用 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 'contains all' :tags
I would like to do something like SELECT x FROM Question x WHERE x.tags 'contains all' :tags
推荐答案
[此搜索 ANY not 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屋!