quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Spring Data API Extension Interface Projections not working with generic interfaces #34350

Open Michael-AT-Corporation opened 1 year ago

Michael-AT-Corporation commented 1 year ago

Describe the bug

When i have a repository like public interface ParentBaseRepository<T extends ParentBase<C>, C extends ChildBase> extends JpaRepository<T, Long> then the generic C causes the method List<T> findAllTestById(Long id); to throw java.lang.IllegalArgumentException: findAllTestById of Repository at.atc.database.repository.ParentRepository can only use interfaces to map results to non-entity types.. When you remove that function then the function GenericParent<C> findChildrenById(Long id); throws the same exception. Both should work.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

I don't know if the code to save a parent with children in the reproducer works because i couldn't test it.

Reproducer: reproducerJPAInterfaceMapping.zip I just in case added the spring boot example: SpringBootJpaTestInterfaceMapping.zip

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @geoand (spring)

geoand commented 1 year ago

This is fixed by #34414

Michael-AT-Corporation commented 1 year ago

@geoand I tried my reproducer with 3.2.1 but it is not working.

Michael-AT-Corporation commented 1 month ago

@geoand I retestet my reproducer with 3.15.1 and the following function in the ParentBaseRepositoryfails:

    GenericParent<C> findChildrenById(Long id);

    interface GenericParent<T extends ChildBase> {
        List<T> getChildren();
    }

The error message:

[error]: Build step io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build threw an exception: java.lang.IllegalArgumentException: findChildrenById of Repository at.atc.database.repository.ParentRepository can only use interfaces to map results to non-entity types.
    at io.quarkus.spring.data.deployment.generate.DerivedMethodsAdder.add(DerivedMethodsAdder.java:195)
    at io.quarkus.spring.data.deployment.generate.SpringDataRepositoryCreator.implementCrudRepository(SpringDataRepositoryCreator.java:117)
    at io.quarkus.spring.data.deployment.SpringDataJPAProcessor.implementCrudRepositories(SpringDataJPAProcessor.java:268)
    at io.quarkus.spring.data.deployment.SpringDataJPAProcessor.build(SpringDataJPAProcessor.java:133)
    at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
geoand commented 1 month ago

Thanks for the update