From 63ff39bed6cf13409c38750ca45110e69b3d9053 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 30 Jun 2015 09:53:19 +0200 Subject: [PATCH] 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: #301. --- .../data/mongodb/core/convert/UpdateMapper.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java index 70433cd8b..b4cb5dd8f 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java @@ -22,7 +22,6 @@ import java.util.Map.Entry; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity; import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.PropertyToFieldNameConverter; @@ -67,8 +66,8 @@ public class UpdateMapper extends QueryMapper { */ @Override protected Object delegateConvertToMongoType(Object source, MongoPersistentEntity entity) { - return entity == null ? super.delegateConvertToMongoType(source, null) : converter.convertToMongoType(source, - getTypeHintForEntity(source, entity)); + return converter.convertToMongoType(source, + entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity)); } /* @@ -200,18 +199,6 @@ public class UpdateMapper extends QueryMapper { this.key = key; } - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public MongoPersistentEntity getPropertyEntity() { - - MongoPersistentEntity entity = super.getPropertyEntity(); - if (entity != null || getProperty() == null) { - return entity; - } - - return new BasicMongoPersistentEntity(getProperty().getTypeInformation()); - } - /* * (non-Javadoc) * @see org.springframework.data.mongodb.core.convert.QueryMapper.MetadataBackedField#getMappedKey()