11
我对JPA
使用eclipselink
。我有一个实体,其中有一个复合键由两个字段组成。以下是我的嵌入式主键类的字段(成员)。嵌入类中的外键映射
@Embeddable
public class LeavePK {
@ManyToOne(optional = false)
@JoinColumn(name = "staffId", nullable = false)
private Staff staff;
@Temporal(TemporalType.TIMESTAMP)
private Calendar date;
//setters and getters
}
我的实体将要举办留下相关的人员数据,所以我尝试要结合员工对象,并离开日期以生产复合键。除了我的逻辑之外,它不允许我在嵌入类中使用外键映射。当我尝试使用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.
这是不是说,我不能有一个键(从组合键),这也是一个外键。有没有其他方法可以完成这种企业风险管理?请帮忙。谢谢