使用Spring Framework JPA
我有Entity
@Entity
@IdClass(ComposityKey.class)
@Table(name="table1")
public class Table1 {
@Id
@Column(name="tableId)
private int tableId;
@Id
private int tableId2;
...
}
第二个Entity
包含对Table1
@Entity
@Table(name = "table2")
public class Table2 {
@ManyToOne
@JoinColumn(name="tableId")
private Table1 table1;
}
现在我得到了明显的AnnotationException
A Foreign key refering Table1 from Table2 has the wrong number of column. should be 2
Table2
没有tableId2
作为值
那么我如何在复合键上JoinColumn
?