71
71
* @author Mark Paluch
72
72
* @author David Julia
73
73
* @author Divya Srivastava
74
+ * @author Ryan Gibb
74
75
*/
75
76
public class QueryMapper {
76
77
@@ -120,6 +121,15 @@ public Document getMappedObject(Bson query, Optional<? extends MongoPersistentEn
120
121
*/
121
122
@ SuppressWarnings ("deprecation" )
122
123
public Document getMappedObject (Bson query , @ Nullable MongoPersistentEntity <?> entity ) {
124
+ return getMappedObjectRecurse (query , entity );
125
+ }
126
+
127
+ protected Document getMappedObjectRecurse (Bson query , Optional <? extends MongoPersistentEntity <?>> entity ) {
128
+ return getMappedObjectRecurse (query , entity .orElse (null ));
129
+ }
130
+
131
+ @ SuppressWarnings ("deprecation" )
132
+ protected Document getMappedObjectRecurse (Bson query , @ Nullable MongoPersistentEntity <?> entity ) {
123
133
124
134
if (isNestedKeyword (query )) {
125
135
return getMappedKeyword (new Keyword (query ), entity );
@@ -317,7 +327,7 @@ protected Entry<String, Object> getMappedObjectForField(Field field, Object rawV
317
327
Object value ;
318
328
319
329
if (rawValue instanceof MongoExpression ) {
320
- return createMapEntry (key , getMappedObject (((MongoExpression ) rawValue ).toDocument (), field .getEntity ()));
330
+ return createMapEntry (key , getMappedObjectRecurse (((MongoExpression ) rawValue ).toDocument (), field .getEntity ()));
321
331
}
322
332
323
333
if (isNestedKeyword (rawValue ) && !field .isIdField ()) {
@@ -366,7 +376,7 @@ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEn
366
376
List <Object > newConditions = new ArrayList <>();
367
377
368
378
for (Object condition : conditions ) {
369
- newConditions .add (isDocument (condition ) ? getMappedObject ((Document ) condition , entity )
379
+ newConditions .add (isDocument (condition ) ? getMappedObjectRecurse ((Document ) condition , entity )
370
380
: convertSimpleOrDocument (condition , entity ));
371
381
}
372
382
@@ -437,7 +447,7 @@ protected Object getMappedValue(Field documentField, Object sourceValue) {
437
447
} else if (valueDbo .containsField ("$ne" )) {
438
448
resultDbo .put ("$ne" , convertId (valueDbo .get ("$ne" ), getIdTypeForField (documentField )));
439
449
} else {
440
- return getMappedObject (resultDbo , Optional .empty ());
450
+ return getMappedObjectRecurse (resultDbo , Optional .empty ());
441
451
}
442
452
return resultDbo ;
443
453
}
@@ -456,7 +466,7 @@ else if (isDocument(value)) {
456
466
} else if (valueDbo .containsKey ("$ne" )) {
457
467
resultDbo .put ("$ne" , convertId (valueDbo .get ("$ne" ), getIdTypeForField (documentField )));
458
468
} else {
459
- return getMappedObject (resultDbo , Optional .empty ());
469
+ return getMappedObjectRecurse (resultDbo , Optional .empty ());
460
470
}
461
471
return resultDbo ;
462
472
@@ -542,15 +552,15 @@ protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersisten
542
552
}
543
553
544
554
if (isDocument (source )) {
545
- return getMappedObject ((Document ) source , entity );
555
+ return getMappedObjectRecurse ((Document ) source , entity );
546
556
}
547
557
548
558
if (source instanceof BasicDBList ) {
549
559
return delegateConvertToMongoType (source , entity );
550
560
}
551
561
552
562
if (isDBObject (source )) {
553
- return getMappedObject ((BasicDBObject ) source , entity );
563
+ return getMappedObjectRecurse ((BasicDBObject ) source , entity );
554
564
}
555
565
556
566
if (source instanceof BsonValue ) {
@@ -566,7 +576,7 @@ protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersisten
566
576
String key = ObjectUtils .nullSafeToString (converter .convertToMongoType (it .getKey ()));
567
577
568
578
if (it .getValue () instanceof Document ) {
569
- map .put (key , getMappedObject ((Document ) it .getValue (), entity ));
579
+ map .put (key , getMappedObjectRecurse ((Document ) it .getValue (), entity ));
570
580
} else {
571
581
map .put (key , delegateConvertToMongoType (it .getValue (), entity ));
572
582
}
0 commit comments