Class UpdateMapper
java.lang.Object
org.springframework.data.mongodb.core.convert.QueryMapper
org.springframework.data.mongodb.core.convert.UpdateMapper
A subclass of
QueryMapper that retains type information on the mongo types.- Author:
- Thomas Darimont, Oliver Gierke, Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.data.mongodb.core.convert.QueryMapper
QueryMapper.AssociationConverter, QueryMapper.Field, QueryMapper.MetadataBackedField -
Field Summary
Fields inherited from class org.springframework.data.mongodb.core.convert.QueryMapper
LOGGER -
Constructor Summary
ConstructorsConstructorDescriptionUpdateMapper(MongoConverter converter) Creates a newUpdateMapperusing the givenMongoConverter. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectconvertValueWithConversionContext(QueryMapper.Field documentField, Object sourceValue, Object value, PropertyValueConverter<Object, Object, ValueConversionContext<MongoPersistentProperty>> valueConverter, MongoConversionContext conversionContext) protected QueryMapper.FieldcreatePropertyField(MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) protected ObjectdelegateConvertToMongoType(Object source, MongoPersistentEntity<?> entity) Converts the given source object to a mongo type retaining the original type information of the source type on the mongo type.org.bson.DocumentgetMappedObject(org.bson.conversions.Bson query, MongoPersistentEntity<?> entity) Replaces the property keys used in the givenDocumentwith the appropriate keys by using thePersistentEntitymetadata.getMappedObjectForField(QueryMapper.Field field, Object rawValue) Extracts the mapped object value for given field out of rawValue taking nestedQueryMapper.Keywords into accountprotected booleanisAssociationConversionNecessary(QueryMapper.Field documentField, Object value) Returns whether the givenQueryMapper.Fieldrepresents an association reference that together with the given value requires conversion to aDBRefobject.static booleanisUpdateObject(org.bson.Document updateObj) Returns true if the givenDocumentis an update object that uses update operators.Methods inherited from class org.springframework.data.mongodb.core.convert.QueryMapper
addMetaAttributes, convertAssociation, convertAssociation, convertId, convertId, convertSimpleOrDocument, createMapEntry, getConverter, getMappedFields, getMappedKeyword, getMappedKeyword, getMappedObject, getMappedSort, getMappedValue, getMappingContext, isDBObject, isDocument, isKeyword, isNestedKeyword, isTypeKey
-
Constructor Details
-
UpdateMapper
Creates a newUpdateMapperusing the givenMongoConverter.- Parameters:
converter- must not be null.
-
-
Method Details
-
getMappedObject
public org.bson.Document getMappedObject(org.bson.conversions.Bson query, @Nullable MongoPersistentEntity<?> entity) Description copied from class:QueryMapperReplaces the property keys used in the givenDocumentwith the appropriate keys by using thePersistentEntitymetadata.- Overrides:
getMappedObjectin classQueryMapper- Parameters:
query- must not be null.entity- can be null.- Returns:
-
isUpdateObject
Returns true if the givenDocumentis an update object that uses update operators.- Parameters:
updateObj- can be null.- Returns:
- true if the given
Documentis an update object.
-
delegateConvertToMongoType
protected Object delegateConvertToMongoType(Object source, @Nullable MongoPersistentEntity<?> entity) Converts the given source object to a mongo type retaining the original type information of the source type on the mongo type.- Overrides:
delegateConvertToMongoTypein classQueryMapper- Returns:
- the converted mongo type or null if source is null
- See Also:
-
getMappedObjectForField
protected Map.Entry<String,Object> getMappedObjectForField(QueryMapper.Field field, Object rawValue) Description copied from class:QueryMapperExtracts the mapped object value for given field out of rawValue taking nestedQueryMapper.Keywords into account- Overrides:
getMappedObjectForFieldin classQueryMapper- Returns:
-
convertValueWithConversionContext
protected Object convertValueWithConversionContext(QueryMapper.Field documentField, Object sourceValue, Object value, PropertyValueConverter<Object, Object, ValueConversionContext<MongoPersistentProperty>> valueConverter, MongoConversionContext conversionContext) - Overrides:
convertValueWithConversionContextin classQueryMapper
-
isAssociationConversionNecessary
protected boolean isAssociationConversionNecessary(QueryMapper.Field documentField, @Nullable Object value) Description copied from class:QueryMapperReturns whether the givenQueryMapper.Fieldrepresents an association reference that together with the given value requires conversion to aDBRefobject. We check whether the type of the given value is compatible with the type of the given document field in order to deal with potential query field exclusions, since MongoDB uses theint0 as an indicator for an excluded field.- Overrides:
isAssociationConversionNecessaryin classQueryMapper- Parameters:
documentField- must not be null.- Returns:
-
createPropertyField
protected QueryMapper.Field createPropertyField(MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) - Overrides:
createPropertyFieldin classQueryMapper- Returns:
-