我的实体映射如下:JPQL多对多查询问题
public class EntertainmentContentBean implements Serializable, Cloneable {
.
.
.
@ManyToMany
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@JoinTable(schema = "etmt", name = "content_operator", joinColumns = @JoinColumn(name = "content_id"), inverseJoinColumns = @JoinColumn(name = "operator_id"))
public Set<Operator> getOperators() {
return operators;
}
.
.
.
}
我已经在这里我想要检索基于以下标准EntertainmentContentBean记录的具体要求:
- 如果没有运营商记录目前
- 如果操作员记录存在,则操作员列表应包含操作员对象通过参数
我尝试下面的查询,但没有返回预期记录:
SELECT NEW MAP (content AS content, id AS record_id)
FROM EntertainmentContentBean contentEntry
WHERE (contentEntry.operators is empty or (select op from Operator op where lower(op.key) = lower(:operator)) MEMBER OF contentEntry.operators))
什么是非常错误的?哪些记录被返回? – axtavt 2011-04-05 10:34:32
记录是一个笛卡尔加入contentEntry.operators表 – 2011-04-05 11:07:50