@ -815,6 +815,11 @@ public class QueryMapper {
@@ -815,6 +815,11 @@ public class QueryMapper {
* /
@Nullable
public Object convertId ( @Nullable Object id , Class < ? > targetType ) {
if ( ! SpecialTypeTreatment . INSTANCE . isConversionCandidate ( id ) ) {
return id ;
}
return converter . convertId ( id , targetType ) ;
}
@ -876,8 +881,8 @@ public class QueryMapper {
@@ -876,8 +881,8 @@ public class QueryMapper {
private Object applyFieldTargetTypeHintToValue ( Field documentField , @Nullable Object value ) {
if ( value = = null | | documentField . getProperty ( ) = = null | | ! documentField . getProperty ( ) . hasExplicitWriteTarget ( )
| | value instanceof Document | | value instanceof DBObject | | value instanceof Pattern
| | value instanceof BsonRegularExpression ) {
| | value instanceof Document | | value instanceof DBObject
| | ! SpecialTypeTreatment . INSTANCE . isConversionCandidate ( value ) ) {
return value ;
}
@ -1604,4 +1609,22 @@ public class QueryMapper {
@@ -1604,4 +1609,22 @@ public class QueryMapper {
throw new IllegalStateException ( "No enclosing property source available" ) ;
}
}
/ *
* Types that must not be converted
* /
enum SpecialTypeTreatment {
INSTANCE ;
private final Set < Class < ? > > types = Set . of ( Pattern . class , BsonRegularExpression . class ) ;
boolean isConversionCandidate ( @Nullable Object value ) {
if ( value = = null ) {
return false ;
}
return ! types . contains ( value . getClass ( ) ) ;
}
}
}