Open dnijssen opened 3 years ago
Thanks for bringing this up!
The methods return type is used for mapping the result documents while the pipeline is mapped against the repository domain type and does not support switching that one via $replaceRoot
.
However, switching the mapping target type based on a domain types property, sounds like an interesting improvement. If you got further suggestions in this direction or even have time for a PR (which would speed up the process) we'd be more than happy to continue the discussion.
Currently the
#computePipelineStage(String, ConvertingParameterAccessor, ParameterBindingDocumentCodec)
method in theReactiveStringBasedAggregation
class maps the pipeline operation sources to the domain class, resulting in fields in a$project
stage being incorrectly being resolved as_id
as its name in the expected return type (Bar) -> namelyidentifier
Consider the following repository with an aggretion query, and 2 data models;
Executing the aggregation results in an instance of
Bar
, however theidentifier
isnull
, due the fact that theReactiveStringBasedAggregation
maps the pipeline stages to the domain class andidentifier
is being transformed to_id
Added a sample project -> https://github.com/dnijssen/mongodb-aggregation