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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user