Adapt to renamed properties by using MappedProperties in association deserialization.
Revert the changes that employed manual annotation lookup as that would cause invalid associations of fields and accessor methods for properties shadow renamed. Instead, we now use MappedProperties that already contains a mapping between the Jackson field names and Spring Data property names. Fixes: #2165 $ Conflicts: $ spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java $ spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2ModuleUnitTests.java
This commit is contained in:
@@ -151,6 +151,10 @@ class MappedProperties {
|
||||
return new MappedProperties(entity, description);
|
||||
}
|
||||
|
||||
public static MappedProperties forDescription(PersistentEntity<?, ?> entity, BeanDescription description) {
|
||||
return new MappedProperties(entity, description);
|
||||
}
|
||||
|
||||
public static MappedProperties none() {
|
||||
return new MappedProperties(Collections.emptyMap(), Collections.emptyMap(), Collections.emptySet(),
|
||||
Collections.emptySet(), false);
|
||||
|
||||
@@ -461,10 +461,12 @@ public class PersistentEntityJackson2Module extends SimpleModule {
|
||||
|
||||
entities.getPersistentEntity(beanDesc.getBeanClass()).ifPresent(entity -> {
|
||||
|
||||
MappedProperties mapped = MappedProperties.forDescription(entity, beanDesc);
|
||||
|
||||
while (properties.hasNext()) {
|
||||
|
||||
SettableBeanProperty property = properties.next();
|
||||
PersistentProperty<?> persistentProperty = entity.getPersistentProperty(property.getName());
|
||||
PersistentProperty<?> persistentProperty = mapped.getPersistentProperty(property.getName());
|
||||
|
||||
if (persistentProperty == null) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user