Skip to content

Commit 63ff39b

Browse files
committed
DATAMONGO-1236 - Polishing.
Removed the creation of a BasicMongoPersistentEntity in favor of always handing ClassTypeInformation.OBJECT into the converter in case not entity can be found. This makes sure type information is written for updates on properties of type Object (which essentially leads to no PersistentEntity being available). Original pull request: spring-projects#301.
1 parent cb0b960 commit 63ff39b

File tree

1 file changed

+2
-15
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert

1 file changed

+2
-15
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.core.convert.converter.Converter;
2323
import org.springframework.data.mapping.Association;
2424
import org.springframework.data.mapping.context.MappingContext;
25-
import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity;
2625
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
2726
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
2827
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.PropertyToFieldNameConverter;
@@ -67,8 +66,8 @@ public UpdateMapper(MongoConverter converter) {
6766
*/
6867
@Override
6968
protected Object delegateConvertToMongoType(Object source, MongoPersistentEntity<?> entity) {
70-
return entity == null ? super.delegateConvertToMongoType(source, null) : converter.convertToMongoType(source,
71-
getTypeHintForEntity(source, entity));
69+
return converter.convertToMongoType(source,
70+
entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity));
7271
}
7372

7473
/*
@@ -200,18 +199,6 @@ public MetadataBackedUpdateField(MongoPersistentEntity<?> entity, String key,
200199
this.key = key;
201200
}
202201

203-
@Override
204-
@SuppressWarnings({ "rawtypes", "unchecked" })
205-
public MongoPersistentEntity<?> getPropertyEntity() {
206-
207-
MongoPersistentEntity<?> entity = super.getPropertyEntity();
208-
if (entity != null || getProperty() == null) {
209-
return entity;
210-
}
211-
212-
return new BasicMongoPersistentEntity(getProperty().getTypeInformation());
213-
}
214-
215202
/*
216203
* (non-Javadoc)
217204
* @see org.springframework.data.mongodb.core.convert.QueryMapper.MetadataBackedField#getMappedKey()

0 commit comments

Comments
 (0)