我正在使用
eclipselink进行JPA.我有一个实体,它有一个由两个字段组成的复合键.以下是我的Embeddable主键类的字段(成员).
@Embeddable
public class LeavePK {
@ManyToOne(optional = false)
@JoinColumn(name = "staffId",nullable = false)
private Staff staff;
@Temporal(TemporalType.TIMESTAMP)
private Calendar date;
//setters and getters
}
我的实体将要保留与工作人员有关的休假数据,所以我试图结合员工对象和离开日期来生成复合密钥.除了我的逻辑,不允许我在embeddable类中有一个外键映射.当我尝试使用JPA工具 – >从实体生成表,它给出错误如下,这解释了,但我没有得到它.
org.eclipse.persistence.exceptions.ValidationException
Exception Description: The mapping [staff] from the embedded ID class [class rs.stapp.entity.LeavePK] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [leavePK] from the source [class rs.stapp.entity.Leave]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded.
这是不是意味着我不能有一个键(复合键),它也是一个外键.有没有办法完成这个企业风险管理?请帮忙.谢谢