java外键实体类_java – 在Embeddable类中的外键映射
我正在使用
eclipselink進(jìn)行JPA.我有一個實體,它有一個由兩個字段組成的復(fù)合鍵.以下是我的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
}
我的實體將要保留與工作人員有關(guān)的休假數(shù)據(jù),所以我試圖結(jié)合員工對象和離開日期來生成復(fù)合密鑰.除了我的邏輯,不允許我在embeddable類中有一個外鍵映射.當(dāng)我嘗試使用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.
這是不是意味著我不能有一個鍵(復(fù)合鍵),它也是一個外鍵.有沒有辦法完成這個企業(yè)風(fēng)險管理?請幫忙.謝謝
總結(jié)
以上是生活随笔為你收集整理的java外键实体类_java – 在Embeddable类中的外键映射的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java利用模板发送邮件_使用JavaM
- 下一篇: mysql学时用什么类型_MYSQL数据