diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java index eaa7b2cb7..876c18eeb 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java @@ -580,7 +580,6 @@ public class QueryMapper { * @return */ @Nullable - @SuppressWarnings("unchecked") protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity entity) { if (source instanceof Example example) { @@ -588,11 +587,8 @@ public class QueryMapper { } if (source instanceof AggregationExpression age) { - - if(entity == null) { - return age.toDocument(); - } - return age.toDocument(new RelaxedTypeBasedAggregationOperationContext(entity.getType(), this.mappingContext, this)); + return entity == null ? age.toDocument() : // + age.toDocument(new RelaxedTypeBasedAggregationOperationContext(entity.getType(), this.mappingContext, this)); } if (source instanceof MongoExpression exr) {