Browse Source

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.
1.6.x
Oliver Gierke 11 years ago
parent
commit
14e352aeae
  1. 17
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java

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

@ -22,7 +22,6 @@ import java.util.Map.Entry; @@ -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 { @@ -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 { @@ -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()

Loading…
Cancel
Save