private void clearNullRelationships(List<Persistent> parentObjects) { for (Persistent object : parentObjects) { if (incoming.readPropertyDirectly(object) instanceof Fault) { incoming.writePropertyDirectly(object, null, null); } } }
/** * Remaps keys in to-many map relationships that contain dirty objects with * potentially modified properties. */ private void remapTargets() { Iterator<Object> it = stateLog.dirtyIds().iterator(); EntityResolver resolver = context.getEntityResolver(); while (it.hasNext()) { ObjectId id = (ObjectId) it.next(); ClassDescriptor descriptor = resolver.getClassDescriptor(id.getEntityName()); Collection<ArcProperty> mapArcProperties = descriptor.getMapArcProperties(); if (!mapArcProperties.isEmpty()) { Object object = getNode(id); for (ArcProperty arc : mapArcProperties) { ToManyMapProperty reverseArc = (ToManyMapProperty) arc .getComplimentaryReverseArc(); Object source = arc.readPropertyDirectly(object); if (source != null && !reverseArc.isFault(source)) { remapTarget(reverseArc, source, object); } } } } }
Object related = property.readPropertyDirectly(object);
/** * Checks if an object has its to-one relationship target modified in memory. */ static boolean isToOneTargetModified( ArcProperty property, Persistent object, ObjectDiff diff) { if (object.getPersistenceState() != PersistenceState.MODIFIED || diff == null) { return false; } if (property.isFault(object)) { return false; } Persistent toOneTarget = (Persistent) property.readPropertyDirectly(object); ObjectId currentId = (toOneTarget != null) ? toOneTarget.getObjectId() : null; // if ObjectId is temporary, target is definitely modified... // this would cover NEW objects (what are the other cases of temp id??) if (currentId != null && currentId.isTemporary()) { return true; } if (!diff.containsArcSnapshot(property.getName())) { return false; } ObjectId targetId = diff.getArcSnapshotValue(property.getName()); return !Util.nullSafeEquals(currentId, targetId); }