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

Panache project() is not working if used with distinct + case-sensitive HQL query #29089

Closed
jasminsuljic opened this issue Nov 7, 2022 · 2 comments · Fixed by #29121
Closed
Assignees
Labels
area/panache kind/bug Something isn't working
Milestone

Comments

@jasminsuljic
Copy link
Contributor

Describe the bug

For an entity that has getter defined with camelCase attribute name ie: myId executing query:

Data.find("SELECT DISTINCT d.myId FROM Data d", Sort.by("myId"))
        .project(Long.class)
        .list();

will result in:

Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: myid of: de.turing85.panache.projection.entity.Data [select distinct new java.lang.Long(d.myid) FROM de.turing85.panache.projection.entity.Data d ORDER BY myId]
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
        at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757)
        at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114)
        at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createQuery(TransactionScopedSession.java:349)
        at org.hibernate.engine.spi.SessionLazyDelegator.createQuery(SessionLazyDelegator.java:547)

The issue is probably here:

Expected behavior

Distinct query should work with HQL compliant query.

Actual behavior

It does not work, an exception is raised.

Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: myid of: de.turing85.panache.projection.entity.Data [select distinct new java.lang.Long(d.myid) FROM de.turing85.panache.projection.entity.Data d ORDER BY myId]
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
        at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757)
        at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114)
        at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createQuery(TransactionScopedSession.java:349)
        at org.hibernate.engine.spi.SessionLazyDelegator.createQuery(SessionLazyDelegator.java:547)

How to Reproduce?

https://github.com/turing85/quarkus-panache-projection/tree/reanme-id-to-myId

Check this line: https://github.com/turing85/quarkus-panache-projection/blob/reanme-id-to-myId/src/main/java/de/turing85/panache/projection/DataResource.java#L36

Output of uname -a or ver

Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000

Output of java -version

openjdk version "19" 2022-09-20 OpenJDK Runtime Environment Homebrew (build 19) OpenJDK 64-Bit Server VM Homebrew (build 19, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.13.3.Final

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

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /Users/jasminsuljic/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 19, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/19/libexec/openjdk.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "12.6", arch: "x86_64", family: "mac"

Additional information

No response

@jasminsuljic jasminsuljic added the kind/bug Something isn't working label Nov 7, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 7, 2022

/cc @FroMage, @loicmathieu

@DavideD DavideD self-assigned this Nov 7, 2022
@DavideD
Copy link
Contributor

DavideD commented Nov 7, 2022

I will have a look.

DavideD added a commit to DavideD/quarkus that referenced this issue Nov 7, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 7, 2022
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 7, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 7, 2022
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 8, 2022
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 8, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 8, 2022
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 8, 2022
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 10, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.
DavideD added a commit to DavideD/quarkus that referenced this issue Nov 10, 2022
@quarkus-bot quarkus-bot bot added this to the 2.15 - main milestone Nov 11, 2022
pedroh-pereira pushed a commit to pedroh-pereira/quarkus that referenced this issue Nov 14, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.
pedroh-pereira pushed a commit to pedroh-pereira/quarkus that referenced this issue Nov 14, 2022
@gsmet gsmet modified the milestones: 2.15 - main, 2.14.1.Final Nov 15, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 15, 2022
When trying to run a select distinct query with projection, Panache will
lowercase the field names.

(cherry picked from commit e6164ca)
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/panache kind/bug Something isn't working
Projects
None yet
3 participants