在带有集合的@Entity 中查询@ElementCollection

Query @ElementCollection in an @Entity with a Collection

假设我有一个@Entity (JPA 2.0)

@Entity    
class Entry {
        @ElementCollection
        Set<String> users = new HashSet();
        @ElementCollection
        Set<String> groups = new HashSet();
}

如何查询它以找到用户为 "John" 且组为 "Foo"、"Bar" 和 "FooBar" 的所有条目?

尝试使用类似这样的东西

@Query("SELECT DISTINCT e FROM Entry e WHERE :user MEMBER OF e.users AND :groups in e.groups")

List<Entry> yourQuery(@Param("user") String user, @Param("groups") List<String> groups);