use of org.apache.cayenne.reflect.ToManyProperty in project cayenne by apache.
the class CayenneContextQueryAction method invalidateLocally.
private void invalidateLocally(CayenneContextGraphManager graphManager, Iterator<?> it) {
if (!it.hasNext()) {
return;
}
EntityResolver resolver = actingContext.getEntityResolver();
while (it.hasNext()) {
final Persistent object = (Persistent) it.next();
// present
if (object.getPersistenceState() == PersistenceState.NEW) {
continue;
}
ObjectId id = object.getObjectId();
// per CAY-1082 ROP objects (unlike CayenneDataObject) require all
// relationship faults invalidation.
ClassDescriptor descriptor = resolver.getClassDescriptor(id.getEntityName());
PropertyVisitor arcInvalidator = new PropertyVisitor() {
public boolean visitAttribute(AttributeProperty property) {
return true;
}
public boolean visitToMany(ToManyProperty property) {
property.invalidate(object);
return true;
}
public boolean visitToOne(ToOneProperty property) {
property.invalidate(object);
return true;
}
};
descriptor.visitProperties(arcInvalidator);
object.setPersistenceState(PersistenceState.HOLLOW);
// remove cached changes
graphManager.changeLog.unregisterNode(id);
graphManager.stateLog.unregisterNode(id);
}
}
Aggregations