I have two tables, PURCHASE_ORDER and ITEM. ITEM has a foreign key to
PRUCHASE_ORDER. Thus, the generated BasePurchaseOrder class has a
getItems() method that returns all the items associated with a PurchaseOrder.
I find myself with code in the Item class that needs to work with its
PurchaseOrder, so it does calls getPurchaseOrder(). The problem is that
this method loads a new copy (and a new object) from PURCHASE_ORDER.
I'd rather have a reference to the original PurchaseOrder. Consider
PurchaseOrder po = PurchaseOrderPeer.retrieveByPK(poid);
for (Item item : po.getItems())
log.info("I'm part of order "+getPurchaseOrder().getID());
Okay, so log.info may be trivial, but you get the point--the
getPurchaseOrder() call will create a new object from the database.
Is there a way I can pre-populate the Items' aPurchaseOrder to the
object I start with (po)?
I know there are some doSelectJoinXXX methods, but they didn't look like
exactly what I wanted. My straw-man approach is to override getItems as
in PurchaseOrder as in