I use JDBCOMGenerator. Fine. I will use Torque soon. . I want to extend my
data object to add functionnalities to the data object without modifing it.
(It allow me to re-generate the Om Layer without having to rewrite my code).
The problem is that the Peer object knows the data object. An example : an
Address table/object. I have the MyAddress extends Address (with more
methods). The doSelect() method create a vector of Address. But I can't cast
from Address to MyAddress. So I have to modify the doSelect method to
generate a vector of MyAddress.
What I propose is to modify the doSelect method. We transmit to this method
the className to generate. For my example, that meens :
/*********************************************************************
public static Vector doSelect(Criteria criteria, String className) throws
Exception
{
criteria.addSelectColumn(address_sid);
criteria.addSelectColumn(state_sid);
criteria.addSelectColumn(zip);
criteria.addSelectColumn(country_iso_code);
criteria.addSelectColumn(town);
criteria.addSelectColumn(address_2);
criteria.addSelectColumn(address_1);
// 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++)
{
Address obj;
if (className != "")
{
obj = (Address) Class.forName(className).newInstance();
}
else
{
obj = new Address();
}
Record row = (Record) rows.elementAt(i);
obj.setAddressSid(row.getValue(1).asInt());
obj.setStateSid(row.getValue(2).asInt());
obj.setZip(row.getValue(3).asString());
obj.setCountryIsoCode(row.getValue(4).asString());
obj.setTown(row.getValue(5).asString());
obj.setAddress2(row.getValue(6).asString());
obj.setAddress1(row.getValue(7).asString());
results.addElement(obj);
}
return results;
}
/***********************************************************
public static Vector doSelect(Criteria criteria) throws Exception
{
return doSelect(criteria, "");
}
/**********************************************************
In fact, this is just a proposal for new Torque.
What do you think about that ??
Herv�
_______________________________
Herv� Guidetti
IDBSoft
Switzerland
[EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]