----- Original Message -----
From: Fedor Karpelevitch <[EMAIL PROTECTED]>
To: Turbine <[EMAIL PROTECTED]>
Sent: Thursday, September 21, 2000 9:42 PM
Subject: Re: Newtorque proposals - contribution proposal
> > 2. doSelect creating subclass of the data object : As I ready expained in
> > some mails earlier ([Proposal] Change *Peer.doSelect() generation -
> Torque)
> > . This is the resolution of 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. That meens :public static Vector doSelect(Criteria criteria,
> > String className).
>
> I think I have a better solution:
>
> DoSelect should not use "new Address()" in this case. Rather than that it
> should define a method:
>
> protected Address createObject()
> {
> return new Address();
> }
>
> and in doSelect simply use "createObject()" instead of "new"
>
> this way, if you simply want MyAddressPeer.doSelect to return a vector of
> MyAddress all you need to do is to overload createObject():
>
> protected Address createObject()
> {
> return new MyAddress();
> }
>
>
> this should be completely transparent and backward-compatible.
> Does it make sense?
The problems comes in when you change your db schema and you want to re-generate
your classes. Any changes that you have made will be overwritten by the newly
generated classes. If you edit the createObject() method to return a subclass
then your changes will also be lost when you re-generate new classes. You might
also want to have different subclasses instantiated at different times. doSelect
(Criteria, Classname) makes this possible, plus it will not break when you
re-generate classes.
~ Leon
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]