hibernate - JPA @Onetomany and @manytoone fetch by part of composite primary key -
i have 2 entities of order , items. in order entity id composite primary key of orderid, userid in items foreign key order id.
how list of items using order id
public class order { @embeddedid private compositeprimarykey pk; @onetomany @joincolumn(name="order_id") private list<items> itemslst; } public class items { @id @column(name="order_id") private integer orderid; }
the above code not working. know table design not good, hard alter design of tables now, alter impact lot of places. keeping current design can on this.
i tried using mappedby , mentioned above in either case getting error.
any help highly appreciated.
if have onetomany between order , item, order_id cannot primary key of item because won't unique. maybe there other issues, obvious 1 can spot without seeing error.
hibernate jpa
No comments:
Post a Comment