@ -15,8 +15,10 @@
* /
* /
package org.springframework.data.mongodb.core.convert ;
package org.springframework.data.mongodb.core.convert ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.LinkedHashMap ;
import java.util.LinkedHashMap ;
import java.util.List ;
import java.util.Map.Entry ;
import java.util.Map.Entry ;
import org.bson.Document ;
import org.bson.Document ;
@ -34,6 +36,7 @@ import org.springframework.data.mongodb.core.query.Update.Modifiers;
import org.springframework.data.util.ClassTypeInformation ;
import org.springframework.data.util.ClassTypeInformation ;
import org.springframework.data.util.TypeInformation ;
import org.springframework.data.util.TypeInformation ;
import org.springframework.lang.Nullable ;
import org.springframework.lang.Nullable ;
import org.springframework.util.ObjectUtils ;
/ * *
/ * *
* A subclass of { @link QueryMapper } that retains type information on the mongo types .
* A subclass of { @link QueryMapper } that retains type information on the mongo types .
@ -221,8 +224,18 @@ public class UpdateMapper extends QueryMapper {
: getMappedSort ( sortObject , field . getPropertyEntity ( ) ) ;
: getMappedSort ( sortObject , field . getPropertyEntity ( ) ) ;
}
}
TypeInformation < ? > typeHint = field = = null ? ClassTypeInformation . OBJECT : field . getTypeHint ( ) ;
if ( isAssociationConversionNecessary ( field , value ) ) {
if ( ObjectUtils . isArray ( value ) | | value instanceof Collection ) {
List < Object > targetPointers = new ArrayList < > ( ) ;
for ( Object val : converter . getConversionService ( ) . convert ( value , List . class ) ) {
targetPointers . add ( getMappedValue ( field , val ) ) ;
}
return targetPointers ;
}
return super . getMappedValue ( field , value ) ;
}
TypeInformation < ? > typeHint = field = = null ? ClassTypeInformation . OBJECT : field . getTypeHint ( ) ;
return converter . convertToMongoType ( value , typeHint ) ;
return converter . convertToMongoType ( value , typeHint ) ;
}
}