java外键实体类_java – 在Embeddable类中的外键映射

我正在使用

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.

这是不是意味着我不能有一个键(复合键),它也是一个外键.有没有办法完成这个企业风险管理?请帮忙.谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值