我正在使用JpaRepositories和Hibernate。
实体类的相关部分如下:
@Entity
public class Person {
//.. id and other attributes
@Column(name = "function")
@ElementCollection
private Set<String> functions;
// .. getter setter
}
我需要将实体类从只能处理一个函数变为可以处理多个函数。
我的 DAO 中有一个搜索功能,可以将所有现有的函数与字符串进行比较,希望找到已定义的函数。
原始的 JPA 查询如下:
select DISTINCT(p.function) from Person p where UPPER(p.function) like UPPER(:term) order by p.function
如何使用新的@ElementCollection实现相同的结果?