public class UpdateMapper extends QueryMapper
QueryMapper
that retains type information on the mongo types.QueryMapper.AssociationConverter, QueryMapper.Field, QueryMapper.MetadataBackedField
LOGGER
Constructor and Description |
---|
UpdateMapper(MongoConverter converter)
Creates a new
UpdateMapper using the given MongoConverter . |
Modifier and Type | Method and Description |
---|---|
protected QueryMapper.Field |
createPropertyField(MongoPersistentEntity<?> entity,
String key,
org.springframework.data.mapping.context.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 given
Document with the appropriate keys by using the
PersistentEntity metadata. |
protected Map.Entry<String,Object> |
getMappedObjectForField(QueryMapper.Field field,
Object rawValue)
Extracts the mapped object value for given field out of rawValue taking nested
Keyword s into account |
protected boolean |
isAssociationConversionNecessary(QueryMapper.Field documentField,
Object value)
Returns whether the given
QueryMapper.Field represents an association reference that together with the given value
requires conversion to a DBRef object. |
static boolean |
isUpdateObject(org.bson.Document updateObj)
Returns true if the given
Document is an update object that uses update operators. |
addMetaAttributes, convertAssociation, convertAssociation, convertId, convertId, convertSimpleOrDocument, createMapEntry, getMappedFields, getMappedKeyword, getMappedKeyword, getMappedObject, getMappedSort, getMappedValue, getMappingContext, isDBObject, isDocument, isKeyword, isNestedKeyword, isTypeKey
public UpdateMapper(MongoConverter converter)
UpdateMapper
using the given MongoConverter
.converter
- must not be null.public org.bson.Document getMappedObject(org.bson.conversions.Bson query, @Nullable MongoPersistentEntity<?> entity)
QueryMapper
Document
with the appropriate keys by using the
PersistentEntity
metadata.getMappedObject
in class QueryMapper
query
- must not be null.entity
- can be null.public static boolean isUpdateObject(@Nullable org.bson.Document updateObj)
Document
is an update object that uses update operators.updateObj
- can be null.Document
is an update object.protected Object delegateConvertToMongoType(Object source, @Nullable MongoPersistentEntity<?> entity)
delegateConvertToMongoType
in class QueryMapper
QueryMapper.delegateConvertToMongoType(java.lang.Object,
org.springframework.data.mongodb.core.mapping.MongoPersistentEntity)
protected Map.Entry<String,Object> getMappedObjectForField(QueryMapper.Field field, Object rawValue)
QueryMapper
Keyword
s into accountgetMappedObjectForField
in class QueryMapper
protected boolean isAssociationConversionNecessary(QueryMapper.Field documentField, @Nullable Object value)
QueryMapper
QueryMapper.Field
represents an association reference that together with the given value
requires conversion to a DBRef
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 the int
0 as an indicator for an excluded field.isAssociationConversionNecessary
in class QueryMapper
documentField
- must not be null.protected QueryMapper.Field createPropertyField(MongoPersistentEntity<?> entity, String key, org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
createPropertyField
in class QueryMapper
Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.