Re: Object not being saved after refaulting and applying changed
Re: Object not being saved after refaulting and applying changed
- Subject: Re: Object not being saved after refaulting and applying changed
- From: Miguel Arroz <email@hidden>
- Date: Fri, 20 Jul 2007 00:17:17 +0100
Hi!
Pardon my ignorance, but is there a way to apply this globally?
IE, change the behaviour of all the ECs to this?
I will actually used an optimized version of this to (try to)
solve my problem, because I can reduce the number of fetches, but it
would be nice to know that this would work fine everywhere.
Yours
Miguel Arroz
PS: Pierre, it would be *really* great to have that bug fixed! ;)
4. Try this instead of refault:
/**
* Forces this object to be re-read from the database; the
snapshot and all editing contexts
* holding this object are updated. Merging or overwriting of
the changes is then handled by
* the editing context delegate. This method takes no action if
the object is pending insertion.
*
* @param anObject the object to be evaluated
*/
public static void refreshObject(EOEnterpriseObject anObject)
{
/** require [valid_theObject_param] anObject != null;
[in_ec] anObject.editingContext() !=
null; **/
// We can't just call editingContext().refreshObject() or
editingContext().refaultObject() the object here.
// That will result in fresh data only if the object is in
a single editing context.
// This seems like the safest way to get fresh data and
inform all of the other
// editing contexts that they need to update.
EOEditingContext ec = anObject.editingContext();
if ( ! ec.insertedObjects().containsObject(anObject))
{
EOQualifier thisObject =
EOUtilities.qualifierForEnterpriseObject(ec, anObject);
EOFetchSpecification fetchSpec = new
EOFetchSpecification(entityForSelf(anObject).name(), thisObject,
NSArray.EmptyArray);
fetchSpec.setRefreshesRefetchedObjects(true);
anObject.editingContext().objectsWithFetchSpecification
(fetchSpec);
}
}
--
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
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
_______________________________________________
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