-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Aggregation criteria match mapping fails with NullPointerException
#4687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@piotrmucha thanks for reporting - I need to check if what happens in the case of an untyped aggregation. It's likely the error stems from there. |
Thank you. I can confirm that replacing untyped aggregation with typed aggregation resolves the problem. var aggregation = Aggregation.newAggregation(match); to: var aggregation = Aggregation.newAggregation(classInstance, match); Makes everyting works. |
thanks for checking @piotrmucha - we'll have a look to get it working with untyped ones as well. |
I've encountered an issue similar to what @piotrmucha described, where the MatchOperation in an aggregation fails with certain _id formats. The test only passes when I modify the _id by adding a prefix. Here's a concise summary of the problem: I'm experienced an issue where a aggregation involving the MatchOperation fails when using certain _id formats. The test passes when I modify the _id by adding a prefix to it. When attempting to match documents by _id using the MatchOperation, the operation fails if the _id is "66014bb53e3e9474cc0f39d2". However, modifying this ID by prefixing it with a character or a number (e.g., "A66014bb53e3e9474cc0f39d2") allows the test to pass. Both IDs are stored as strings in MongoDB.
Using typed aggregations also fixed this case:
While this resolved the issue for me, I thought it was still worth mentioning here as it may highlight a deeper problem or help creating better test coverage. |
NullPointerException
…ria query. Resolves: spring-projects#4687 Original pull request: spring-projects#4695
Reformat code. Remove superfluous warning suppressions. See spring-projects#4687 Original pull request: spring-projects#4695
spring-data-mongodb version: 4.2.4
I am trying to move following query from JSON to MongoTemplate:
I have tried following approach:
But it doesn't work, exception like this is thrown:
What's wrong here? Is it possible to use MongoExpression Criteria inside MatchOperation stage?
The text was updated successfully, but these errors were encountered: