micronaut-projects / micronaut-data

Ahead of Time Data Repositories
Apache License 2.0
465 stars 197 forks source link

Overriding findAll() results in exception #3096

Closed volgin closed 1 month ago

volgin commented 2 months ago

Expected Behavior

This should work:

    @Override
    @NonNull
    List<Genre> findAll();

Actual Behaviour

An exception is thrown:

java.lang.IllegalStateException: Micronaut Data method is missing compilation time query information. Ensure that the Micronaut Data annotation processors are declared in your build and try again with a clean re-build.
    at io.micronaut.data.runtime.intercept.DataInterceptorResolver.findDataInterceptor(DataInterceptorResolver.java:111)
    at io.micronaut.data.runtime.intercept.DataInterceptorResolver.resolve(DataInterceptorResolver.java:77)
    at io.micronaut.data.runtime.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:75)
    at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:138)
    at com.kingfishertom.snobs.repository.GenreRepository$Intercepted.findAll(Unknown Source)

Steps To Reproduce

All other repositories in the project work as expected. All other methods in this repository work as expected: I am able to override findById(), etc. So this is not an "annotation processors are declared" issue as the exception suggests.

When I do not override findAll(), it also works, but I need to override it so I can add @Join annotation.

Environment Information

No response

Example Application

No response

Version

4.5.0

dstepanov commented 2 months ago

Please attach a sample project that is reproducing it

volgin commented 2 months ago

This is a project to demo the issue:

https://github.com/volgin/snobs-bug-demo.git

Note that findById test works, while findAll test fails.

radovanradic commented 2 months ago

I am not getting compilation errors and the tests are passing (I just adjusted connection to my local db and disabled that listener which can't use locally, not sure what it is doing).

dstepanov commented 2 months ago

Is it failing when run using maven or just from IDE?

volgin commented 2 months ago
  1. I was using IDE. When I tried mvn clean verify and mvn test, all tests passed. Even more curiously, now when I run tests in Eclipse, they also pass.

I have not thought of trying maven, because in a real project there many more repositories and tests, and all tests were working except for this one. Something prevented Micronaut from precompiling just this one query.

  1. I went to the original project and tried this test again in Eclipse. In failed. Then I tried mvn test. It failed.

mvn clean verify worked. After mvn clean verify, both mvn test and Eclipse test work.

This is really strange, because I did try to clean the project using Eclipse, but it did not solve the problem.

dstepanov commented 1 month ago

It looks like some IDE problems unrelated to Micronaut

graemerocher commented 1 month ago

we recommend either IntelliJ or VScode