The only way to achieve this in general would be modifying the object.vm template which generatates the get${relCol} method.
I would believe that the behaviour you describe would make sense generally. Any opinions on that from other people ? By doing this one would increase coupling between objects. Thomas > Maybe the subject makes sense. Let me explain. > > 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 > this code: > > PurchaseOrder po = PurchaseOrderPeer.retrieveByPK(poid); > for (Item item : po.getItems()) > item.doWork(); > > in Item.doWork(): > > 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 > > @Override > public List<Item> getItems() throws TorqueException > { > List<Item> items = super.getItems(); > > for (Item item : items) > item.setPurchaseOrder(this); > > return items; > } > > but this seems tacky to use on every call. > > Brendan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org > For additional commands, e-mail: torque-user-h...@db.apache.org >