假设我有一个 @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);
关于java - 使用集合查询 @Entity 中的 @ElementCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34121907/