Hi,
I would not like to take away the normal doSelect (Criteria) method for two
reasons. The first is that you would break some code if the newly generated
classes does not have that method and second you'll need to type the
class-name every time you call doSelect.
I can see the usefulness of this approach so I think we should overload the
doSelect() method in the Peer class that so that it can optionally take the
class-name as a parameter. On top of that I think we should add a static
final string to the Peer class that defines the default class-name that will
be instantiated if you do not supply a class-name with your doSelect.
Anybody as any other thoughts on this?
My ISP made it impossible for me to do any CVS updates or commits :-( I'll
try and commit the template based Torque tomorrow (Friday). It'll be easy
to add this code to the template...
~ Leon
>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
>enerate 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]