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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to