This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi I haven't used hibernate for quite some time now and im presented with this situation.
I have 3 tables with different fields but they are all purchase orders and have a set of order_items. (as seen on image) I have a table purchase_order_items which contains all the items of each purchase order may it be type 1,2,3. How do I map this with the hbm.xml .
I should have a one is to many relationship with table to purchase order items , table 2 to purchase order items , table 3 to purchas order items. Is that possible? how do i configure the purchase order item table.
Not, inside it - it would have three subclasses (no quite the same thing). But each one of those subtypes would inherit the one-to-many relationship.
Something like this:
When you map that in Hibernate, as I understand it there are three strategies that you can use. You can map them to a single table (using an extra column to indicate the actual type). You can use a table for the superclass, and then extra tables for each subtype (containing any additional fields that you add in the subclass). Or you use table-per-concrete-class, which I think would match the structure you've got.