We have this legacy DB with two tables as follows:
Code:
TableA {
columnA PK;
columnB PK;
columnC;
columnD;
}
TableB {
columnC PK; //same as TableA.columnC
columnE PK;
columnF;
columnG;
}
and the relationship is that TableA.columnC = TableB.ColumnC
We also have objects defined for these that presently is used by a custom persistence framework.
Code:
public class A{
private int columnA;
private String columnB;
private int columnC;
private Date columnD;
private List listBs; //this contains a collection of class B
......
}
public class B{
private int columnC;
private int columnE;
private int columnF;
private Date columnG;
....
}
How do i map these?
As you can see above, A can have one to many Bs. But, B is related to A only by a non-key column of A. When I use a bag to map these, i get the following exception:
Code:
net.sf.hibernate.MappingException: Foreign key must have same number of columns as referenced primary key
How do I map this?