Properly deep-merge nested documents on PUT.
This is needed to consider read-only properties within those objects as those would otherwise get overridden. Fixes: #2174
This commit is contained in:
@@ -40,6 +40,7 @@ import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||
import org.springframework.data.rest.webmvc.mapping.Associations;
|
||||
import org.springframework.data.rest.webmvc.util.InputStreamHttpInputMessage;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.Optionals;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -61,6 +62,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
* @author Craig Andrews
|
||||
* @author Mathias Düsterhöft
|
||||
* @author Thomas Mrozinski
|
||||
* @author Lars Vierbergen
|
||||
* @since 2.2
|
||||
*/
|
||||
public class DomainObjectReader {
|
||||
@@ -686,7 +688,7 @@ public class DomainObjectReader {
|
||||
} else if (property.isCollectionLike()) {
|
||||
result = mergeCollections(property, sourceValue, targetValue, mapper);
|
||||
} else if (property.isEntity()) {
|
||||
result = mergeForPut(sourceValue, targetValue, mapper);
|
||||
result = Optionals.mapIfAllPresent(sourceValue, targetValue, (l, r) -> mergeForPut(l, r, mapper));
|
||||
} else {
|
||||
result = sourceValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user