Today I updated Spring Boot from version 2.2.2.RELEASE to 2.5.2. After that aggregations started to behave differently. Here is an example query (in kotlin language):
val aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("_id").isEqualTo(ObjectId("6faa215a23cfcf1524cc4a4b"))),
Aggregation.project().andExclude("_id").andExpression("\$\$ROOT").`as`("user"),
Aggregation.lookup("user", "user._id", "_id", "sameUser")
)
return reactiveMongoTemplate.aggregate(aggregation, "user", UserTestAgggr::class.java)
data class UserTestAgggrUserTestAgggr(
val user: User,
val sameUser: User
)
For 2.2.2.RELEASE version this code worked. However in version 2.5.2 API requires sameUser
param to be a list (otherwise it throws an exception).
I would like to avoid modifying my queries or objects (because I've got too many of those). So I guess my question is: is there a way to make most recent API behave like before without a downgrade?
So my answer was to create my own MappingMongoConverter, which was a nightmare, because it had to extend MappingMongoConverter (some spring classes inject MappingMongoConverter directly instead of using MongoConverter interface). Had to write it in java as well (so I could rely on MappingMongoConverter original implementation). Not fun at all, but solved the issue for me.