Java JPA Hibernate在@ElementCollection上选择distinct并比较
我正在将Hibernate与JpaRepositories一起使用 实体类的相关部分为:Java JPA Hibernate在@ElementCollection上选择distinct并比较,java,spring,hibernate,jpa,Java,Spring,Hibernate,Jpa,我正在将Hibernate与JpaRepositories一起使用 实体类的相关部分为: @Entity public class Person { //.. id and other attributes @Column(name = "function") @ElementCollection private Set<String> functions; // .. getter setter } 如何使用新的@Element
@Entity
public class Person {
//.. id and other attributes
@Column(name = "function")
@ElementCollection
private Set<String> functions;
// .. getter setter
}
如何使用新的@ElementCollection存档相同的结果?您需要将集合加入到
Person
中,然后选择。请尝试以下查询:
select DISTINCT(f) from Person p join p.functions f where UPPER(f) like UPPER(:term) order by f
select DISTINCT(f) from Person p join p.functions f where UPPER(f) like UPPER(:term) order by f