-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
@Meta
annotation not working properly with MongoRepository
and custom repositories
#4852
Comments
@malaquf a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem would help a lot. Thank you! |
@christophstrobl thank you for the very fast answer. Sorry for that, here it goes: https://github.com/malaquf/spring-data-mongodb-issue-4852 |
There are a couple of aspects and the fix isn't trivial. When using Going forward, there are a few things we need to consider:
|
MongoRepository
and custom repositories
MongoRepository
and custom repositories@Meta
annotation not working properly with MongoRepository
and custom repositories
Interesting! Thank you for the info. I did some quick research and it seems I could simply replace Do you see a better/simpler approach to intercept the queries and append a default maxTimeMS? |
Ok, I think this should be good for my use cases:
|
Unfortunately, it is not that easy, as it turned out, command is immutable. |
It looks like I'm also aware of this new mongodb driver feature, and would also like to ask you to consider supporting it soon: https://jira.mongodb.org/browse/JAVA-3828 Thank you. |
Hello @mp911de, |
Environment:
Kotlin with coroutines 2.1.0
Spring Boot 3.3.1
Problem
When adding a @meta annotation to my queries in a given repository, I get empty lists as result.
Unfortunately, I could not find the root cause yet, but I hope the following description helps to reproduce it.
CrudMethodMetadataPopulatingMethodInterceptor checks if a method is a query using
isQueryMethod()
. Because @meta adds @QueryAnnotation, the method is not added toSet<Method> implementations
.Surprisingly, query methods defined in repositories by default are added to
Set<Method> implementations
from CrudMethodMetadataPopulatingMethodInterceptor, and everything works fine when not adding the @meta annotation.The difference I see so far is in the execution path for the query in the following method:
When adding @meta annotation, my query is executed through
invocation.proceed()
withinif (!implementations.contains(method))
block. If @meta is not present, the execution is done by the rest of the code.Repository example:
I'll update the issue if I have more information.
By the way, all I want in this case is to define maxExecutionTimeMs for my queries and I believe there should be a better way to customise it (and specially set a default) without having to define it for each method in the repository. Like having an interceptor for easily extending the Query options, for example.
Thank you for looking into it.
The text was updated successfully, but these errors were encountered: