You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Marc Lustig <ml...@marclustig.com> on 2003/02/19 15:46:01 UTC
how to generate removeObject() methods? (was: AW: how to tell the bo that a foreign collection must be reloaded?)
Also, my torque-generated user objects don't have any removeObject()
methods. (addObject()'s are available).
Why is that?
torque.complexObjectModel=true
> -----Ursprüngliche Nachricht-----
> Von: Peter S. Hamlen [mailto:phamlen@mail.com]
> Gesendet: Dienstag, 18. Februar 2003 19:39
> An: Turbine Torque Users List
> Betreff: Re: how to tell the bo that a foreign collection must be
> reloaded?
>
>
> Well, depending on what you're doing, there are several answers:
>
> 1) If you get the foreign object from the collObjects list, then you
> don't need to do anything (because the object is still in the list and
> has been changed in place.)
>
> 2) If you're adding or removing foreign objects, then you may need to
> reload the list.
> a) The easiest way is to use the addObject() and removeObject()
> methods in the user object. This automatically adds/removes the foreign
> object from the collObjects list and no reload is necessary.
> b) In the cases where (for whatever reason) you can't use the
> addObject and removeObject functions, you may need to alter the base
> Template that generates your classes. We added a "clearCollection"
> function to all our obejcts that clears these collObjects. (I realize
> this means altering the templates which people may not feel like doing.)
>
> Hope this helps.
> -Peter
>
> On Sat, 2003-02-15 at 18:12, Marc Lustig wrote:
> > Hi,
> > I have related an attribute of the user over the foreign key.
> > The foreign objects are stored in the collObjects List.
> > After I changed one of the related objects, what is the proper
> way to tell
> > my user object that this object-collection needs to be updated (reloaded
> > from db)?
> > Problem is even if I call user.getObjects(new Criteria()) this
> doesn't make
> > sure that the collection will be reloaded since the last
> request might also
> > have used an empty criteria.
> > Idea?
> >
> > Marc
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
AW: how to generate removeObject() methods? (was: AW: how to tellthe bo that a foreign collection must be reloaded?)
Posted by Marc Lustig <ml...@marclustig.com>.
[I sent this email 20 mins ago, due to some strange reason it didn't get
distributed, at least not to me.]
> 4) Deleting objects is a little trickier. Essentially, you need to
> remove the object from collObjects, and THEN delete the object. (The
> save() function on the parent object will NOT delete removed objects.)
>
> So the code fragment might look like:
>
> Person p = PersonPeer.retrieveByPK(114);
- PersonAddresss addrList = p.getPersonAddresss();
+ List addrList = p.getPersonAddresss();
> PersonAddress addr1 = addrList.get(0);
^?
- addr1.remove(0);
+ addrList.remove(0);
> PersonAddressPeer.doDelete(addr1);
Many thanks, Peter. Your code would compile only with the above changes.
But still it would not work.
Am I right that this is the way you are doing the removal?
PersonAddress addr1 = getObjectToRemove
Person p = PersonPeer.retrieveByPK(114);
List addrList = p.getPersonAddresss();
addrList.remove(addrList.indexOf(addr1));
PersonAddressPeer.doDelete(addr1);
Re: how to generate removeObject() methods? (was: AW: how to tellthe bo that a foreign collection must be reloaded?)
Posted by "Peter S. Hamlen" <ph...@mail.com>.
My mistake. That's not in the regular Torque templates.
You can look at my previous post for more information.
-Peter
On Wed, 2003-02-19 at 09:46, Marc Lustig wrote:
> Also, my torque-generated user objects don't have any removeObject()
> methods. (addObject()'s are available).
> Why is that?
>
> torque.complexObjectModel=true
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Peter S. Hamlen [mailto:phamlen@mail.com]
> > Gesendet: Dienstag, 18. Februar 2003 19:39
> > An: Turbine Torque Users List
> > Betreff: Re: how to tell the bo that a foreign collection must be
> > reloaded?
> >
> >
> > Well, depending on what you're doing, there are several answers:
> >
> > 1) If you get the foreign object from the collObjects list, then you
> > don't need to do anything (because the object is still in the list and
> > has been changed in place.)
> >
> > 2) If you're adding or removing foreign objects, then you may need to
> > reload the list.
> > a) The easiest way is to use the addObject() and removeObject()
> > methods in the user object. This automatically adds/removes the foreign
> > object from the collObjects list and no reload is necessary.
> > b) In the cases where (for whatever reason) you can't use the
> > addObject and removeObject functions, you may need to alter the base
> > Template that generates your classes. We added a "clearCollection"
> > function to all our obejcts that clears these collObjects. (I realize
> > this means altering the templates which people may not feel like doing.)
> >
> > Hope this helps.
> > -Peter
> >
> > On Sat, 2003-02-15 at 18:12, Marc Lustig wrote:
> > > Hi,
> > > I have related an attribute of the user over the foreign key.
> > > The foreign objects are stored in the collObjects List.
> > > After I changed one of the related objects, what is the proper
> > way to tell
> > > my user object that this object-collection needs to be updated (reloaded
> > > from db)?
> > > Problem is even if I call user.getObjects(new Criteria()) this
> > doesn't make
> > > sure that the collection will be reloaded since the last
> > request might also
> > > have used an empty criteria.
> > > Idea?
> > >
> > > Marc
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>