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
ConstructorDescriptionUpdateMapper
(MongoConverter converter) Creates a newUpdateMapper
using the givenMongoConverter
. -
Method Summary
Modifier and TypeMethodDescriptionprotected QueryMapper.Field
createPropertyField
(MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) protected Object
delegateConvertToMongoType
(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.Document
getMappedObject
(org.bson.conversions.Bson query, MongoPersistentEntity<?> entity) Replaces the property keys used in the givenDocument
with the appropriate keys by using thePersistentEntity
metadata.getMappedObjectForField
(QueryMapper.Field field, Object rawValue) Extracts the mapped object value for given field out of rawValue taking nestedQueryMapper.Keyword
s into accountprotected boolean
isAssociationConversionNecessary
(QueryMapper.Field documentField, Object value) Returns whether the givenQueryMapper.Field
represents an association reference that together with the given value requires conversion to aDBRef
object.static boolean
isUpdateObject
(org.bson.Document updateObj) Returns true if the givenDocument
is 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 newUpdateMapper
using 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:QueryMapper
Replaces the property keys used in the givenDocument
with the appropriate keys by using thePersistentEntity
metadata.- Overrides:
getMappedObject
in classQueryMapper
- Parameters:
query
- must not be null.entity
- can be null.- Returns:
-
isUpdateObject
Returns true if the givenDocument
is an update object that uses update operators.- Parameters:
updateObj
- can be null.- Returns:
- true if the given
Document
is 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:
delegateConvertToMongoType
in 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:QueryMapper
Extracts the mapped object value for given field out of rawValue taking nestedQueryMapper.Keyword
s into account- Overrides:
getMappedObjectForField
in classQueryMapper
- Returns:
-
isAssociationConversionNecessary
protected boolean isAssociationConversionNecessary(QueryMapper.Field documentField, @Nullable Object value) Description copied from class:QueryMapper
Returns whether the givenQueryMapper.Field
represents an association reference that together with the given value requires conversion to aDBRef
object. 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 theint
0 as an indicator for an excluded field.- Overrides:
isAssociationConversionNecessary
in classQueryMapper
- Parameters:
documentField
- must not be null.- Returns:
-
createPropertyField
protected QueryMapper.Field createPropertyField(MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) - Overrides:
createPropertyField
in classQueryMapper
- Returns:
-