Could someone illustrate the proper way to wire up your annotations in a parent/child relationship amongst 3 or more objects? For example, a purchase order has a header, multiple lines, and each line contains a collection of shipments:
PurchaseOrder (Pk = auto generated HEADER_ID)
PurchaseOrderLine (Pk = HEADER_ID + LINE_NUMBER) PurchaseOrderLineShipment PurchaseOrderLineShipment
PurchaseOrderLine (Pk = HEADER_ID + LINE_NUMBER + SHIPMENT_NUMBER) PurchaseOrderLineShipment
For the child records, the line and shipment numbers are assigned by my code. What I see happen is that the HEADER_ID from the quote header gets set on the line records prior to their INSERT; however, I do not see this same behavior happen properly on the shipment level. When Hibernate goes to save the shipments, it errors saying that the HEADER_ID is NULL and that the table does not permit NULLs.
Any help is greatly appreciated.
|