How to write JPA query where parameter is a set?
问题 Assuming the following class, how do you find a Person with a particular email address? public class Person implements Comparable<Person> { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") private long id = 0; @OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}, fetch=FetchType.LAZY) private Set<String> email = new HashSet<String>(); } Is it as simple as doing just this, or is there a proper way? select p from Person p where p.email=:email 回答1