DATAES-471 - Adapt object property access behavior after changes in Spring Data Commons.

Changes made for Spring Data Commons result in final fields being rejected for manipulation unless there's a wither method available on the object at hand. Unfortunately adapting Spring Data Elasticsearch to support that doesn't work easily as it requires breaking changes to ElasticsearchTemplate as most of the methods assume parameters being handed to be mutable, see the implementation of SimpleElasticsearchRepository.save(…) for instance.

We now mitigate the problem, by enforcing the BeanWrapperPropertyAccessor being used and treating all properties as mutable.

Related tickets: DATACMNS-1322.
This commit is contained in:
Oliver Gierke 2018-07-12 15:27:36 +02:00
parent 143a359eca
commit cdbc832068
No known key found for this signature in database
GPG Key ID: 6E42B5787543F690
2 changed files with 23 additions and 0 deletions

View File

@ -28,7 +28,9 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Parent;
import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.model.BasicPersistentEntity;
import org.springframework.data.mapping.model.PersistentPropertyAccessorFactory;
import org.springframework.data.util.TypeInformation;
import org.springframework.expression.Expression;
import org.springframework.expression.ParserContext;
@ -195,4 +197,16 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
this.scoreProperty = property;
}
}
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.model.BasicPersistentEntity#setPersistentPropertyAccessorFactory(org.springframework.data.mapping.model.PersistentPropertyAccessorFactory)
*/
@Override
public void setPersistentPropertyAccessorFactory(PersistentPropertyAccessorFactory factory) {
// Do nothing to avoid the usage of ClassGeneratingPropertyAccessorFactory for now
// DATACMNS-1322 switches to proper immutability behavior which Spring Data Elasticsearch
// cannot yet implement
}
}

View File

@ -85,4 +85,13 @@ public class SimpleElasticsearchPersistentProperty extends
public boolean isScoreProperty() {
return isScore;
}
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#isImmutable()
*/
@Override
public boolean isImmutable() {
return false;
}
}