DbRelationship masterDependentDbRel = descriptor.getPathFromMaster().get(0);
if (masterDependentDbRel != null) {
for (final DbJoin dbAttrPair : masterDependentDbRel.getJoins()) {
DbAttribute dbAttribute = dbAttrPair.getTarget();
if (!attributes.contains(dbAttribute)) {
attributes.add(dbAttribute);
valueTransformers.add(new Transformer() {
public Object transform(Object input) {
ObjectId id = (ObjectId) ((ObjectDiff) input).getNodeId();
return id.getIdSnapshot().get(dbAttrPair.getSourceName());
}
});
}
}
}
}
if (usingOptimisticLocking) {
for (final ObjAttribute attribute : descriptor.getEntity().getAttributes()) {
if (attribute.isUsedForLocking()) {
// only care about first step in a flattened attribute
DbAttribute dbAttribute = (DbAttribute) attribute
.getDbPathIterator()
.next();
if (!attributes.contains(dbAttribute)) {
attributes.add(dbAttribute);
valueTransformers.add(new Transformer() {
public Object transform(Object input) {
return ((ObjectDiff) input).getSnapshotValue(attribute
.getName());
}
});
}
}
}
for (final ObjRelationship relationship : descriptor
.getEntity()
.getRelationships()) {
if (relationship.isUsedForLocking()) {
// only care about the first DbRelationship
DbRelationship dbRelationship = relationship
.getDbRelationships()
.get(0);
for (final DbJoin dbAttrPair : dbRelationship.getJoins()) {
DbAttribute dbAttribute = dbAttrPair.getSource();
// relationship transformers override attribute transformers for
// meaningful FK's... why meaningful FKs can go out of sync is
// another story (CAY-595)
int index = attributes.indexOf(dbAttribute);
if (index >= 0 && !dbAttribute.isForeignKey()) {
continue;
}
Transformer transformer = new Transformer() {