更新:看下面我的答案如何檢查2個列表相交(無論是@ElementCollection
用字符串/枚舉和往常一樣的實體列表映射像@OneToMany
)HQL。兩個列表
我有一個包含@ElementCollection
領域的實體與枚舉。
public enum StatusType {
NEW, PENDING, CLOSED;
}
@Entity
public class MyEntity {
@ElementCollection
@CollectionTable(name = "status_type", joinColumns = {@JoinColumn(name = "my_entity_id")})
@Column(name = "status_type", nullable = false)
private Set<StatusType > statusTypes = new HashSet<StatusType >();
...
}
現在我想其中包含狀態NEW
或PENDING
(或兩者)的所有實體。
我試圖用這個查詢:
SELECT DISTINCT u FROM MyEntity u WHERE u.statusTypes in :statusTypes
但我發現了異常:org.postgresql.util.PSQLException: No value specified for parameter 9.
如何正確的收集和過濾器通過交叉查詢?