DATACMNS-1322 - Add support for immutable entities in PersistentPropertyAccessor.setProperty(PersistentPropertyPath, Object).

As setting a PersistentProperty can actually change the object that the property is changed on, we now recursively traverse property paths up as longs as the setting of the property results in the bean not being replaced.
This commit is contained in:
Oliver Gierke
2018-06-18 16:49:01 +02:00
parent 6cb3587ba3
commit d1ebfcfc5e
2 changed files with 51 additions and 1 deletions

View File

@@ -71,9 +71,21 @@ public interface PersistentPropertyAccessor {
getBean().getClass().getName()));
}
PersistentPropertyAccessor accessor = leafProperty.getOwner().getPropertyAccessor(parent);
PersistentPropertyAccessor accessor = parent == getBean() //
? this //
: leafProperty.getOwner().getPropertyAccessor(parent);
accessor.setProperty(leafProperty, value);
if (parentPath.isEmpty()) {
return;
}
Object bean = accessor.getBean();
if (bean != parent) {
setProperty(parentPath, bean);
}
}
/**