views:

95

answers:

1

I have this escenario... I have three 4 entities {orderItem, suppliers, supplier, prices}, and they are related like:

OrderItem 1->* suppliers (some one item can have many supplier prices)

Suppliers 1->1 supplier

Suppliers 1->1 itemPrices

and it's properties

OrderItem {orderId, partId, quantity, suppliers}

Suppliers {orderId, partId, Supplier}

And there my proble goes...

What would be the best way to embed the Suppliers entity to the OrderItem Entity, please forget about the relation between suppliers with supplier and itemprice this is already done using join columns.

Will something like

@JoinTable(name = "Suppliers", joinColumns = { @JoinColumn(name = "orderid", referencedColumnName = "orderid") }, inverseJoinColumns = { @JoinColumn(name = "partid", referencedColumnName = "partid") })

will work?

or:

@OneToMany(mappedBy="orderid, partid")
private List<Suppliers> suppliers;

for example..

A: 

Will not embed the Suppliers class to the OrderItem as i will use the orderid and partid for the relation. So, using those keys i will with a new method call for that list searching with the orderid and the partid...

Garis Suero