Skip to content
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

Quarkus Spring Data DTO and Projections support #13050

Closed
engilyin opened this issue Nov 1, 2020 · 3 comments · Fixed by #14118
Closed

Quarkus Spring Data DTO and Projections support #13050

engilyin opened this issue Nov 1, 2020 · 3 comments · Fixed by #14118
Labels
area/spring Issues relating to the Spring integration kind/enhancement New feature or request
Milestone

Comments

@engilyin
Copy link

engilyin commented Nov 1, 2020

Describe the bug
Spring Data API supports DTO and Projections.
Here you can read how it should work:
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections

Expected behavior
DTO and Projections should work

Actual behavior
It just try to retrieve the full object and fails with Cast error:

Caused by: java.lang.ClassCastException: class org.acme.entities.Contact cannot be cast to class org.acme.data.SimpleContactProjection (org.acme.entities.Contact and org.acme.data.SimpleContactProjection are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @363f6148)

To Reproduce
Please check this repo:
https://github.com/engilyin/quarkus-spring-dto.git

All tests should be passed (build succeed):
./gradlew clean build

Also you can find commented out stuff in this repo. That was my try to use dynamic projections/DTO.
It breaks build at all.

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin MacBook-Pro-Alexander.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

  • Output of java -version: openjdk 11.0.5 2019-10-15 LTS

  • Quarkus version or git rev: 1.9.1.Final

  • Build tool (ie. output of mvnw --version or gradlew --version): Gradle 6.6.1

@engilyin engilyin added the kind/bug Something isn't working label Nov 1, 2020
@quarkusbot
Copy link

/cc @geoand

@quarkusbot quarkusbot added the area/spring Issues relating to the Spring integration label Nov 1, 2020
@geoand geoand added kind/enhancement New feature or request and removed kind/bug Something isn't working labels Nov 1, 2020
@ghost ghost added this to the 1.11 - master milestone Jan 6, 2021
@engilyin
Copy link
Author

Does not look like this issue was fixed.
Keep getting this error for my tests.

org.acme.resteasy.ContactResourceTest > testDto() FAILED
    java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build threw an exception: java.lang.IllegalArgumentException: findByUsername of Repository org.acme.repositories.SimpleContactDtoRepository can only use interfaces to map results to non-entity types.
        at io.quarkus.spring.data.deployment.generate.DerivedMethodsAdder.add(DerivedMethodsAdder.java:187)
        at io.quarkus.spring.data.deployment.generate.SpringDataRepositoryCreator.implementCrudRepository(SpringDataRepositoryCreator.java:116)
        at io.quarkus.spring.data.deployment.SpringDataJPAProcessor.implementCrudRepositories(SpringDataJPAProcessor.java:273)
        ```

@geoand
Copy link
Contributor

geoand commented Mar 14, 2021

Can you create a new issue and include a project that reproduces the behavior you mention?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants