Re: Nested Editing Contexts
Re: Nested Editing Contexts
- Subject: Re: Nested Editing Contexts
- From: Jonathan Rochkind <email@hidden>
- Date: Mon, 21 Jul 2003 18:00:26 -0500
When you set a relationship from one object to another:
someEmployee.setEmployee( someDepartment)
or
someEmployee.addObjectToBothSidesOfRelationshipWithKey( someDepartment,
"department")
Both objects must be in the same editing context. That is,
someEmployee.editingContext() == someDepartment.editingContext().
If you don't do this, you will get the very uninformative error you see
below, at the point of saveChanges(). At the point you set the
relationship, you won't get the exception, but rather at the point of
saveChanges().
This is definitely one of the most often and most painful mistakes made
when working with multiple editing contexts. To move an object from one EC
to another, for the purpose of using it in a relationship, use
EOUtilities.localInstanceOfObject.
--Jonathan
At 05:29 PM 7/21/2003 -0500, Albert Jagnow wrote:
I have changed the application I am currently working on to use nested
editing contexts based on some earlier discussion that it might be a
better/safer way of doing things. A very simple description of what I
have is like the following:
ec = session().defaultEditingContext();
nestedEc = new EOEditingContext(ec);
EOEnterpriseObject eo = new EOEnterpriseObject();
nestedEc.insertObject(eo);
user updates eo and clicks save
nestedEc.saveChanges();
ec.saveChanges();
When ec.saveChanges() is called I get the error "Cannot obtain globalId
for and object which is registered in an other than the
databaseContext's active editingContext,..." I assume I am not
understanding some simple concept about how nested editing contexts
should work. Could someone attempt to explain to me what I am doing
wrong.
--Albert
This e-mail (including any attachments) is covered by the Electronic
Communications Privacy Act, 18 USC. 2510-2521. It is confidential and
may be legally privileged. If you are not the intended recipient, you
are hereby notified that any retention, dissemination, distribution, or
copying of this communication is strictly prohibited. Please reply to
the sender that you have received the message in error, and then delete
it. Thank you.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.