Skip to content

MongoTemplate.aggregate(…, Map.class) considers Map an entity projection #5115

@nealeu

Description

@nealeu

This appears to be a regression when migrating to Spring Data MongoDB 5.0.0, as there's nothing in the release notes about this.

Everywhere we project to a Map, when we do:

var result = mongoOperations.aggregate(aggregation, Map.class)

we get

No mapping metadata found for java.lang.Object
org.springframework.data.mapping.MappingException: No mapping metadata found for java.lang.Object
	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.doReadProjection(MappingMongoConverter.java:397)
	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.project(MappingMongoConverter.java:366)

WORKAROUND: In our case we can replace the Map with a record with the fields we need.

Metadata

Metadata

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions