static void unsetReverse(
final Persistent sourceObject,
String propertyName,
final Persistent targetObject) {
ArcProperty property = (ArcProperty) Cayenne
.getClassDescriptor(sourceObject)
.getProperty(propertyName);
ArcProperty reverseArc = property.getComplimentaryReverseArc();
if (reverseArc != null) {
reverseArc.visit(new PropertyVisitor() {
public boolean visitToMany(ToManyProperty property) {
property.removeTargetDirectly(targetObject, sourceObject);
return false;
}
public boolean visitToOne(ToOneProperty property) {
property.setTarget(targetObject, null, false);
return false;
}
public boolean visitAttribute(AttributeProperty property) {
return false;
}
});
sourceObject.getObjectContext().getGraphManager().arcDeleted(
targetObject.getObjectId(),
sourceObject.getObjectId(),
reverseArc.getName());
markAsDirty(targetObject);
}
}