[EMAIL PROTECTED] wrote on 12/13/05 3:57 PM:
I can change any of the attributes

[snip]

However, while I can change [a relationship]
and I even verify it is stored in the database, my WODisplayGroup still shows the old value.

In my experience, WO will update attributes persisted to the DB, but for relations it only pulls from its cache. Even when you call setRefreshesRefetchedObjects(true) on a fetch spec, related objects are still pulled from the cache instead of from the DB. You may be encountering something different by throwing display groups into the mix, but the behaviour seems to be similar.

To guarantee fresh relations, I either call setPrefetchingRelationshipKeyPaths(NSArray relation-names) on the fetch-spec or I call a relationship-loading method (code below) on the list I get back from the fetch.

HTH --

zak.

public static void preloadRelationship(NSArray sourceEOs, String relationshipName)
{
if (sourceEOs == null || sourceEOs.count() == 0)
return;

EOEnterpriseObject sampleEO = (EOEnterpriseObject) sourceEOs.objectAtIndex(0);
EOEditingContext ec = sampleEO.editingContext();
EOObjectStoreCoordinator osc = (EOObjectStoreCoordinator) ec.rootObjectStore();
osc.lock();
try
{
EOEntity entity = EOModelGroup.modelGroupForObjectStoreCoordinator(osc).entityNamed(sampleEO.entityName()); EODatabaseContext databaseContext = EODatabaseContext.registeredDatabaseContextForModel(entity.model(), osc);
EORelationship relationship = entity.relationshipNamed(relationshipName);
databaseContext.batchFetchRelationship(relationship, sourceEOs, ec);
}
finally
{
osc.unlock();
}
}

_______________________________________________
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