[英]Hibernate the same column in the primary key and in the id
我的表具有多個主鍵,因此必須創建可嵌入的類。 該鍵中的一列是指向另一張表的外鍵。 如何為其創建JPA注釋?
public class ControlPlanLineEmbeddable implements Serializable{
@Column(name = "[Control Plan No_]")
String controlPlanNo;
@Column(name ="[Version]")
String version;
@Column(name ="[Line No_]")
int lineNo;
@ManyToOne
@JoinColumn(name="Control Plan No_")
ControlPlanSetup xxx;
....
所以我只有3列,我正在嘗試創建4個注釋。 列Control Plan No_
是不同表中主鍵的一部分,也是外鍵的一部分。 我必須創建@ManyToOne
批注,但是我收到:
從POJO.ControlPlanLine引用POJO.ControlPlanSetup的外鍵具有錯誤的列數。 應該是4
上一次,我還需要使我的PK也成為另一個實體的FK。 有了幫助
@MapsId
來自(javax.persistence.MapsId;)的注釋。 我敢肯定,使用它可以解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.