Using Spring Framework JPA I have an Entity
@Entity
@IdClass(ComposityKey.class)
@Table(name="table1")
public class Table1 {
@Id
@Column(name="tableId)
private int tableId;
@Id
private int tableId2;
...
}
2nd Entity contains a reference to Table1
@Entity
@Table(name = "table2")
public class Table2 {
@ManyToOne
@JoinColumn(name="tableId")
private Table1 table1;
}
Now I'm getting the obvious AnnotationException
A Foreign key refering Table1 from Table2 has the wrong number of column. should be 2
Table2 doesn't have tableId2 as a value
So how can i JoinColumn on a Composite Key?