0
我嘗試創建複合鍵多對一的關係,但是當我插入我的前S2豆我已經得到了這個錯誤:Play2/JPA/Ebean一對多映射,採用了複合的PrimaryKey
[error] Caused by: org.h2.jdbc.JdbcSQLException: Duplicate column name "CODE1"; SQL statement:
[error] insert into Pres2 (code1, code2, code3, champ1, code1) values (?,?,?,?,?) [42121-172]
我謨是玩2.2.2。
你能幫我解決我的問題嗎?
我對豆PRES1第一ID類代碼:
@Embeddable
public class ClePres1 implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "code1")
private String code1;
@Override
public int hashCode() {
...
}
@Override
public boolean equals(Object obj) {
...
}
我的豆PRES1代碼:
@Entity
@Table(Name = "Pres1")
public class Pres1 extends Model {
private static final long serialVersionUID = 1L;
@EmbeddedId
ClePres1 cle;
@OneToMany(mappedBy = "pres1")
private List<Pres2> listPres2;
...
我第二次爲豆ID類前S2代碼:
@Embeddable
public class ClePres2 implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "code1")
public String code1;
@Column(name = "code2")
public String code2;
@Column(name = "code3")
public String code3;
@Override
public int hashCode() {
...
}
@Override
public boolean equals(Object obj) {
...
}
我的前S2豆:
@Entity
@Table(name = "Pres2")
public class Pres2 extends Model {
private static final long serialVersionUID = 1L;
@EmbeddedId
ClePres2 cle;
@Column(name = "champ1")
private String champ1;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "code1",referencedColumnName="code1")
})
private Pres1 pres1;
請發佈Pres3實體,它看起來像在嵌入以及實體中都有code1列。 –
對不起,這只是一個錯誤的副本/過去我已編輯我的問題。總是Pres1和Pres2 – flagadajones