public void editingContextDidSaveChanges(NSNotification n) {
EOEditingContext ec = (EOEditingContext) n.object();
final boolean isNestedEditingContext = (ec.parentObjectStore() instanceof EOEditingContext);
NSArray insertedObjects = (NSArray)n.userInfo().objectForKey("inserted");
NSArray updatedObjects = (NSArray)n.userInfo().objectForKey("updated");
NSArray deletedObjects = (NSArray)n.userInfo().objectForKey("deleted");
ERXEnterpriseObject.DidUpdateProcessor.perform(ec, updatedObjects);
ERXEnterpriseObject.DidDeleteProcessor.perform(ec, deletedObjects);
ERXEnterpriseObject.DidInsertProcessor.perform(ec, insertedObjects);
if ( isNestedEditingContext ) {
// we can assume insertedObjectGIDs and updatedObjectGIDs are non null. if we execute this branch, they're at
// least empty arrays.
final EOEditingContext parentEC = (EOEditingContext)ec.parentObjectStore();
if (insertedObjects.count() > 0 || updatedObjects.count() > 0) {
NSMutableArray flushableObjects = new NSMutableArray();
flushableObjects.addObjectsFromArray(insertedObjects);
flushableObjects.addObjectsFromArray(updatedObjects);
parentEC.lock();
try {
final NSArray flushableObjectsInParent = ERXEOControlUtilities.localInstancesOfObjects(parentEC, flushableObjects);
if ( log.isDebugEnabled() ) {
log.debug("saveChanges: before save to child context " + ec +
", need to flush caches on objects in parent context " + parentEC + ": " + flushableObjectsInParent);
}