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

Sort Bug in HQL Query That Has Alias #38581

Closed
yasarmatrac opened this issue Feb 5, 2024 · 2 comments
Closed

Sort Bug in HQL Query That Has Alias #38581

yasarmatrac opened this issue Feb 5, 2024 · 2 comments
Labels
area/hibernate-orm Hibernate ORM area/panache kind/bug Something isn't working

Comments

@yasarmatrac
Copy link

Describe the bug

In HQL queries, if I use 'io.quarkus.panache.common.Sort' with a query that has an alias then the application throws org.hibernate.query.SemanticException.

Person.find("select distinct p from Person p left join p.roles r", Sort.by("p.name")).list()

The code block creates this following HQL.

select distinct p from Person p left join p.roles r ORDER BY 'p.name'

In 'io.quarkus.panache.hibernate.common.runtime.PanacheJpaUtil.toOrderBy' method causes this exception. In the method, fields are enquoted and HQL couldn't be interpreted.

image

Expected behavior

Hql queries that have aliases should be used with sort aliases

Actual behavior

The application throws the following error.
java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: Could not interpret path expression 'p.name' at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:143) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:167) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:173) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:848) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:753) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:136) at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createQuery(TransactionScopedSession.java:367)

How to Reproduce?

Person.find("select distinct p from Person p left join p.roles r", Sort.by("p.name")).list()

Output of uname -a or ver

No response

Output of java -version

17

Quarkus version or git rev

3.7.1

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

No response

Additional information

No response

@yasarmatrac yasarmatrac added the kind/bug Something isn't working label Feb 5, 2024
@geoand geoand added area/hibernate-orm Hibernate ORM and removed triage/needs-triage labels Feb 5, 2024
Copy link

quarkus-bot bot commented Feb 5, 2024

/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

@yrodiere
Copy link
Member

yrodiere commented Feb 5, 2024

Thanks for reporting, but it appears this duplicates #38521 , which will be fixed in 3.7.2.

I'll close this issue, feel free to answer here if you think this is a mistake.

@yrodiere yrodiere closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/panache kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants