@@ -373,7 +373,9 @@ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEn
373
373
if (keyword .isOrOrNor () || (keyword .hasIterableValue () && !keyword .isGeometry ())) {
374
374
375
375
Iterable <?> conditions = keyword .getValue ();
376
- List <Object > newConditions = conditions instanceof Collection ? new ArrayList <>(((Collection <?>) conditions ).size ()) : new ArrayList <>();
376
+ List <Object > newConditions = conditions instanceof Collection
377
+ ? new ArrayList <>(((Collection <?>) conditions ).size ())
378
+ : new ArrayList <>();
377
379
378
380
for (Object condition : conditions ) {
379
381
newConditions .add (isDocument (condition ) ? getMappedObject ((Document ) condition , entity )
@@ -431,8 +433,10 @@ protected Object getMappedValue(Field documentField, Object sourceValue) {
431
433
432
434
Object value = applyFieldTargetTypeHintToValue (documentField , sourceValue );
433
435
434
- if (documentField .getProperty () != null && converter .getCustomConversions ().hasValueConverter (documentField .getProperty ())) {
435
- return converter .getCustomConversions ().getPropertyValueConversions ().getValueConverter (documentField .getProperty ())
436
+ if (documentField .getProperty () != null
437
+ && converter .getCustomConversions ().hasValueConverter (documentField .getProperty ())) {
438
+ return converter .getCustomConversions ().getPropertyValueConversions ()
439
+ .getValueConverter (documentField .getProperty ())
436
440
.write (value , new MongoConversionContext (documentField .getProperty (), converter ));
437
441
}
438
442
@@ -616,7 +620,11 @@ protected Object delegateConvertToMongoType(Object source, @Nullable MongoPersis
616
620
}
617
621
618
622
protected Object convertAssociation (Object source , Field field ) {
619
- return convertAssociation (source , field .getProperty ());
623
+ Object value = convertAssociation (source , field .getProperty ());
624
+ if (value != null && field .isIdField () && field .getFieldType () != value .getClass ()) {
625
+ return convertId (value , field .getFieldType ());
626
+ }
627
+ return value ;
620
628
}
621
629
622
630
/**
@@ -1042,6 +1050,9 @@ public TypeInformation<?> getTypeHint() {
1042
1050
return TypeInformation .OBJECT ;
1043
1051
}
1044
1052
1053
+ public Class <?> getFieldType () {
1054
+ return Object .class ;
1055
+ }
1045
1056
}
1046
1057
1047
1058
/**
@@ -1170,6 +1181,11 @@ private Association<MongoPersistentProperty> findAssociation() {
1170
1181
return null ;
1171
1182
}
1172
1183
1184
+ @ Override
1185
+ public Class <?> getFieldType () {
1186
+ return property .getFieldType ();
1187
+ }
1188
+
1173
1189
@ Override
1174
1190
public String getMappedKey () {
1175
1191
return path == null ? name : path .toDotPath (isAssociation () ? getAssociationConverter () : getPropertyConverter ());
0 commit comments