Query @ElementCollection in an @Entity with a Collection
问题 Let's say that I have an @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"? 回答1: 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);