[英]Query @ElementCollection in an @Entity with a Collection
Let's say that I have an @Entity (JPA 2.0) 假设我有一个@Entity(JPA 2.0)
@Entity
class Entry {
@ElementCollection
Set<String> users = new HashSet();
@ElementCollection
Set<String> groups = new HashSet();
}
How can I query it to find all Entries where users is "John" and groups are "Foo", "Bar" and "FooBar"? 如何查询它以查找用户为“ John”且组为“ Foo”,“ Bar”和“ FooBar”的所有条目?
Try using something like this 尝试使用类似这样的东西
@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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.