Skip to content

Commit cdbc832

Browse files
committed
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.
1 parent 143a359 commit cdbc832

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import org.springframework.data.elasticsearch.annotations.Parent;
2929
import org.springframework.data.elasticsearch.annotations.Setting;
3030
import org.springframework.data.mapping.MappingException;
31+
import org.springframework.data.mapping.PersistentPropertyAccessor;
3132
import org.springframework.data.mapping.model.BasicPersistentEntity;
33+
import org.springframework.data.mapping.model.PersistentPropertyAccessorFactory;
3234
import org.springframework.data.util.TypeInformation;
3335
import org.springframework.expression.Expression;
3436
import org.springframework.expression.ParserContext;
@@ -195,4 +197,16 @@ public void addPersistentProperty(ElasticsearchPersistentProperty property) {
195197
this.scoreProperty = property;
196198
}
197199
}
200+
201+
/*
202+
* (non-Javadoc)
203+
* @see org.springframework.data.mapping.model.BasicPersistentEntity#setPersistentPropertyAccessorFactory(org.springframework.data.mapping.model.PersistentPropertyAccessorFactory)
204+
*/
205+
@Override
206+
public void setPersistentPropertyAccessorFactory(PersistentPropertyAccessorFactory factory) {
207+
208+
// Do nothing to avoid the usage of ClassGeneratingPropertyAccessorFactory for now
209+
// DATACMNS-1322 switches to proper immutability behavior which Spring Data Elasticsearch
210+
// cannot yet implement
211+
}
198212
}

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,13 @@ protected Association<ElasticsearchPersistentProperty> createAssociation() {
8585
public boolean isScoreProperty() {
8686
return isScore;
8787
}
88+
89+
/*
90+
* (non-Javadoc)
91+
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#isImmutable()
92+
*/
93+
@Override
94+
public boolean isImmutable() {
95+
return false;
96+
}
8897
}

0 commit comments

Comments
 (0)