我有以下实体
@Entity
public class Conversation implements Serializable {
@Id
private int Id;
@Column
private Alias AliasA;
// SNIP
}
和
@Entity
public class Alias implements Serializable {
@Id
private String alias;
@Column
private String personalName;
@OneToMany(mappedBy = "alias", cascade = CascadeType.ALL)
@MapKeyColumn(name="address")
private Map<String, Recipient> recipients = new HashMap<String, Recipient>();
}
和
@Entity
public class Recipient implements Serializable {
@Id
@GeneratedValue
private long id;
@Column
private String address;
@Column
private RecipientStatus status;
@ManyToOne
private Alias alias;
}
我想做类似下面的 JPQL 查询
SELECT conversation FROM Conversation conversation WHERE :sender MEMBER OF conversation.aliasA.recipients AND conversation.adId=:adID
我的地图的键在哪里:sender
。然而,该MEMBER OF
关键字似乎只适用于集合而不适用于地图。我相信 JPA 2.0 应该提供KEY
关键字,但这似乎还没有在 OpenJPA 中实现。有没有替代方案?
更新:添加信息以澄清我的问题。