I am having some trouble trying to find a solution for this and I think it may not be possible at all, but I'll still give it a try here. So lets pretend my legacy DB schema on MySQL with MyISAM (no FKs) has the following 2 tables:
TblOrder
ORDERID (INT) PK
CUSTOMERID (INT) PK
REPID (INT) PK
ISORDER (INT) PK
other columns...
TblOrderPos
ORDERID (INT) PK
POSITIONID (INT) PK
other columns
What would my annotations have to look like to allow TblOrder to have a Set of TblOrderPos (identyfied by ORDERID) and TblOrderPos a private TblOrder instance? I did create EmbeddedId objects for both tables and everytime I try to create a property with @ManyToOne or @OneToMany overriding @JoinColumns Hibernate complains that the number of PK columns does not match (well it cant).
I really hope somebody has an idea or if it's possible at all.
-----------update------------
On TblOrder
@OneToMany(mappedBy="shoporder")
@JoinColumn(name="ORDERID")
public List<Orderposition> getOrderpositions(){
return this.positions;
}
public void setOrderPositions(List<Orderposition> positions){
this.positions = positions;
}
On TblOrderPos
@ManyToOne
@JoinColumn(name="ORDERID")
public Shoporder getShoporder(){
return this.shoporder;
}
public void setShoporder(Shoporder order){
this.shoporder = order;
}
That's the error I keep getting: A Foreign key refering TblOrder from TblOrderPos has the wrong number of column. should be 4