@ -30,6 +30,8 @@ import org.bson.types.ObjectId;
@@ -30,6 +30,8 @@ import org.bson.types.ObjectId;
import org.springframework.core.convert.ConversionService ;
import org.springframework.core.convert.converter.Converter ;
import org.springframework.data.annotation.Reference ;
import org.springframework.data.convert.PropertyValueConverter ;
import org.springframework.data.convert.ValueConversionContext ;
import org.springframework.data.domain.Example ;
import org.springframework.data.mapping.Association ;
import org.springframework.data.mapping.MappingException ;
@ -40,6 +42,7 @@ import org.springframework.data.mapping.PropertyPath;
@@ -40,6 +42,7 @@ import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.mapping.PropertyReferenceException ;
import org.springframework.data.mapping.context.InvalidPersistentPropertyPath ;
import org.springframework.data.mapping.context.MappingContext ;
import org.springframework.data.mapping.model.PropertyValueProvider ;
import org.springframework.data.mongodb.MongoExpression ;
import org.springframework.data.mongodb.core.aggregation.AggregationExpression ;
import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext ;
@ -437,9 +440,22 @@ public class QueryMapper {
@@ -437,9 +440,22 @@ public class QueryMapper {
if ( documentField . getProperty ( ) ! = null
& & converter . getCustomConversions ( ) . hasValueConverter ( documentField . getProperty ( ) ) ) {
return converter . getCustomConversions ( ) . getPropertyValueConversions ( )
. getValueConverter ( documentField . getProperty ( ) )
. write ( value , new MongoConversionContext ( null , documentField . getProperty ( ) , converter ) ) ;
MongoConversionContext conversionContext = new MongoConversionContext ( new PropertyValueProvider < > ( ) {
@Override
public < T > T getPropertyValue ( MongoPersistentProperty property ) {
throw new IllegalStateException ( "No enclosing property available" ) ;
}
} , documentField . getProperty ( ) , converter ) ;
PropertyValueConverter < Object , Object , ValueConversionContext < MongoPersistentProperty > > valueConverter = converter
. getCustomConversions ( ) . getPropertyValueConversions ( ) . getValueConverter ( documentField . getProperty ( ) ) ;
/* might be an $in clause with multiple entries */
if ( ! documentField . getProperty ( ) . isCollectionLike ( ) & & sourceValue instanceof Collection < ? > collection ) {
return collection . stream ( ) . map ( it - > valueConverter . write ( it , conversionContext ) ) . collect ( Collectors . toList ( ) ) ;
}
return valueConverter . write ( value , conversionContext ) ;
}
if ( documentField . isIdField ( ) & & ! documentField . isAssociation ( ) ) {