Re: EOEditing Context Error
Re: EOEditing Context Error
- Subject: Re: EOEditing Context Error
- From: Chuck Hill <email@hidden>
- Date: Tue, 6 Jun 2006 17:07:11 -0700
On Jun 6, 2006, at 5:00 PM, Robyn Hughes wrote:
I am trying to save changes to the the editing context using this
code and get the error below. Can anyone help?
try
{
//fetch the three primary keys needs for creating the
subTopicResults instance
TrackingObject trackingObject = (TrackingObject)
com.webobjects.eoaccess.EOUtilities.objectMatchingKeyAndValue
(ec,"TrackingObject","trackingObjectName","Performance Planner");
TopicName topicName = (TopicName)
com.webobjects.eoaccess.EOUtilities.objectMatchingKeyAndValue
(ec,"TopicName","topicName","Performance Planner");
SubTopicName subTopicName = (SubTopicName)
com.webobjects.eoaccess.EOUtilities.objectMatchingKeyAndValue
(ec,"SubTopicName","subTopicName",subTopicPageName);
if (trackingObject != null && topicName != null && subTopicName !=
null)
{
//create a new instance of subTopicResults
subTopicResults = ( SubTopicResults)
com.webobjects.eoaccess.EOUtilities.createAndInsertInstance
(ec,"SubTopicResults");
//add the relationships
subTopicResults.addObjectToBothSidesOfRelationshipWithKey
(trackingObject,"trackingObject");
subTopicResults.addObjectToBothSidesOfRelationshipWithKey
(((Session)session()).currentUser,"recipient");
That looks like the most likely cause. ((Session)session
()).currentUser.editingContext() != ec
Try
User user = (User) EOUtilities.localInstanceOfObject(ec, ((Session)
session()).currentUser);
subTopicResults.addObjectToBothSidesOfRelationshipWithKey
(user,"recipient");
subTopicResults.addObjectToBothSidesOfRelationshipWithKey
(topicName,"topicName");
subTopicResults.addObjectToBothSidesOfRelationshipWithKey
(subTopicName,"subTopicName");
}
save();
}
catch (Exception e)
{
throw e;
}
Error:
java.lang.IllegalStateException: prepareForSaveWithCoordinator:
com.webobjects.eoaccess.EODatabaseContext@ad552c is currently
saving for com.webobjects.eocontrol.EOEditingContext@6e119d so it
cannot prepare to save for
com.webobjects.eocontrol.EOEditingContext@6e119d.
com.webobjects.eocontrol.EOObjectStoreCoordinator@86684c has
sources (com.webobjects.eoaccess.EODatabaseContext@ad552c,
com.webobjects.eoaccess.EODatabaseContext@b248c8)
Means, "you have an object in one editing context related to an
object in another editing context. This is not allowed."
Chuck
--
Coming sometime... - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
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