> If I want to define a BO based on more than one table, what is the best
> design if I'm using Peer classes ? a small example will be nice.
I'm doing something of the sort in one of my apps. It might not be the
cleanest way, but it works - and best of all: Good Performance! I tested a
couple of ways to do this, and this is by far the best performance whise!
For this app I have models that each have a specific vendor. In other words
a one-to-many relation between vendor and model. If I want to select models
with their associated Vendors I do it like this (I use some code that is
generated by newtorque and not the current torque version):
public static Vector doSelectWithVendor ( Criteria criteria ) throws
Exception
{
// First add the model rows to select
addSelectColumns (criteria);
// Now we add all to Vendor rows as well
VendorPeer.addSelectColumns (criteria);
// Force a join
criteria.addJoin (VENDOR_ID, VendorPeer.VENDOR_ID);
// BasePeer returns a Vector of Value (Village) arrays. The array
// order follows the order columns were placed in the Select clause.
Vector rows = BasePeer.doSelect(criteria);
Vector results = new Vector();
// populate the object(s)
for ( int i=0; i<rows.size(); i++ )
{
Record row = (Record)rows.elementAt(i);
// Get the model from the first half of the row
Model model = row2Object (row,1);
// Get the vendor from the second half of the row
Vendor vendor = VendorPeer.row2Object (row,12);
// Add the vendor to the model
model.setVendor (vendor);
results.addElement (model);
}
return results;
}
> Is it supported by Torque until now ?
We're thinking of features to add to torque, but I think it will probably be
a while before this is fully supported.
~ Leon
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]