开发者

JPA Entities with JoinColumn of two columns

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 = "ord开发者_JS百科erid") }, inverseJoinColumns = { @JoinColumn(name = "partid", referencedColumnName = "partid") })

will work?

or:

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

for example..


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜