It looks like the save function sits in your objects, so my guess is
that as part of user.save() you also must call address.save() (maybe
user.get('addresses').save() ?)

That seems logical to me, but others may have some better ideas.  I
think in my current models I would pass User to my UserService for this.
UserService would probably need to be AddressService aware and then pass
Address in to talk to the AddressDAO. 

We're currently doing an XML integration, so I turn the object into XML
and pass it on to a web service (so, yes, looping and some recursion),
so my brain isn't in database mode right now...

anthony

-----Original Message-----
From: Aaron Roberson [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 16, 2007 12:07 PM
To: cfcdev@cfczone.org; Anthony Israel-Davis
Subject: Re: [CFCDEV] ORM: Generic Child Array in Parent Bean

Anthony,

I am reviving this issue again because I am wondering what must take
place on the persistence side to save my user and all of the addresses
related to it?

In other words, once I have done user.set("addresses",addresses); how do
I turn around and do user.save() to persist all of the addresses?
Must I add some business logic in my userDAO to loop through the
addresses and persist them?

Thanks,
Aaron

On 3/21/07, Anthony Israel-Davis <[EMAIL PROTECTED]> wrote:
>
> In that scenario, what I would do is something like:
>
> addresses = createObject("component","AddressIBO").init();
> addresses.loadQuery(query);
> user.set('addresses',addresses);
>
> You've created an address object that now can be a property of the 
> user object ("composition" in OO speak)
>
> Now you can do this:
>
> a = user.get('addresses');
>
> While (a.hasNext()) {
>         doSomethingToA(a);
> }
>
> BTW, I created a hasNext() method which is similar to isLast() but 
> checks whether iterator is GT than numRecords. It made more sense in 
> while loops.
>
> I'm also planning on adding "add" and "remove" methods, but I haven't 
> needed them (yet) but now I'm off-topic ;-)
>
> Anthony




You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/cfcdev@cfczone.org

Reply via email to