Re: Child editing context simple (?) question :-)
Re: Child editing context simple (?) question :-)
- Subject: Re: Child editing context simple (?) question :-)
- From: Chuck Hill <email@hidden>
- Date: Fri, 27 Mar 2009 07:52:32 -0700
On Mar 27, 2009, at 7:10 AM, Ricardo J. Parada wrote:
Hi All,
I need to iron out this one now. :-) I'm gonna borrow David
Leber's example from his blog at http://davidleber.net :
EOEditingContext parentEc = ERXEC.newEditingContext();
Person person = Person.newPerson(parentEc);
EOEditingContext childEc = ERXEC.newEditingContext(parentEc);
Person personInChild = person.localInstance(childEc);
Address address = Address.newAddress(childEc);
personInChild.addObjectToBothSidesOfRelationshipWithKey(address,
"addresses");
childEc.saveChanges(); // move changes into my parent
Notice that person is a new EO (i.e. never been saved to the
database). The address EO is also new except that it is being
created in the child editing context.
Now, saving the child editing context is supposed to push the
changes to the parent editing context, except that it fails in my
test case because I have the following mandatory relationship:
Person <-->> Address
How is something like this handled? Am I supposed to make the
relationship optional or is there another way around this?
Local instance can copy from parent to child. Yes, even unsaved EOs.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden