0
我有兩個實體來說甲一個實體,B 其中A是和B之一是許多休眠如何映射設定在我有兩個鍵
答:
@Entity
@Table(name = "A")
class A...{
@Id
@Column(name = "A2id",nullable = false)
private Integer A2id;
@Id
@Column(name = "A1id",nullable = false)
private Integer A1id;
@OneToMany(mappedBy="a")
private Set<B> Bset;
//get's set's and public c'tor
}
B相類似這樣的
@Entity
@Table(name = "B")
public class B implements Serializable{
//id's
@Id
@Column(name = "B1id", nullable = false)
private Integer B1id;
@Id
@Column(name = "B2id",nullable = false)
private Integer B2id;
@ManyToOne
@JoinColumn(name="B2id",nullable = false)
private A a;
//get's set's and public c'tor
}
和休眠呼喊對我道:
一個外鍵引用com。 .A from com。 .B的列數錯誤。應該是2
有什麼問題呢? 請幫我