You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I call the hasNextPage() method (io.quarkus.hibernate.orm.panache.PanacheQuery#hasNextPage) on a query in HQL , which contains an entity field with name written in camel case (eg. groupId)), I receive the following error:
Could not interpret path expression 'groupid'
org.hibernate.query.SemanticException: Could not interpret path expression 'groupid'
at org.hibernate.query.hql.internal.BasicDotIdentifierConsumer$BaseLocalSequencePart.resolvePathPart(BasicDotIdentifierConsumer.java:241)
at org.hibernate.query.hql.internal.BasicDotIdentifierConsumer.consumeIdentifier(BasicDotIdentifierConsumer.java:92)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimplePath(SemanticQueryBuilder.java:5259)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitIndexedPathAccessFragment(SemanticQueryBuilder.java:5218)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGeneralPathFragment(SemanticQueryBuilder.java:5193)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGeneralPathExpression(SemanticQueryBuilder.java:1886)
at org.hibernate.grammars.hql.HqlParser$GeneralPathExpressionContext.accept(HqlParser.java:7967)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitBarePrimaryExpression(HqlParserBaseVisitor.java:777)
at org.hibernate.grammars.hql.HqlParser$BarePrimaryExpressionContext.accept(HqlParser.java:7425)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitExpressionOrPredicate(HqlParserBaseVisitor.java:917)
at org.hibernate.grammars.hql.HqlParser$ExpressionOrPredicateContext.accept(HqlParser.java:8195)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitFinalFunctionArgument(SemanticQueryBuilder.java:4296)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGenericFunctionArguments(SemanticQueryBuilder.java:4273)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGenericFunctionArguments(SemanticQueryBuilder.java:275)
at org.hibernate.grammars.hql.HqlParser$GenericFunctionArgumentsContext.accept(HqlParser.java:12784)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.getFunctionArguments(SemanticQueryBuilder.java:4176)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGenericFunction(SemanticQueryBuilder.java:4041)
at org.hibernate.grammars.hql.HqlParser$GenericFunctionContext.accept(HqlParser.java:12413)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitFunction(HqlParserBaseVisitor.java:1309)
at org.hibernate.grammars.hql.HqlParser$FunctionContext.accept(HqlParser.java:11891)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitFunctionExpression(SemanticQueryBuilder.java:1897)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitFunctionExpression(SemanticQueryBuilder.java:275)
at org.hibernate.grammars.hql.HqlParser$FunctionExpressionContext.accept(HqlParser.java:7847)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitBarePrimaryExpression(HqlParserBaseVisitor.java:777)
at org.hibernate.grammars.hql.HqlParser$BarePrimaryExpressionContext.accept(HqlParser.java:7425)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitExpressionOrPredicate(HqlParserBaseVisitor.java:917)
at org.hibernate.grammars.hql.HqlParser$ExpressionOrPredicateContext.accept(HqlParser.java:8195)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectableNode(SemanticQueryBuilder.java:1430)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelection(SemanticQueryBuilder.java:1407)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectClause(SemanticQueryBuilder.java:1400)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuery(SemanticQueryBuilder.java:1249)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:1035)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:275)
at org.hibernate.grammars.hql.HqlParser$QuerySpecExpressionContext.accept(HqlParser.java:2132)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:1020)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:275)
at org.hibernate.grammars.hql.HqlParser$SimpleQueryGroupContext.accept(HqlParser.java:2003)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectStatement(SemanticQueryBuilder.java:490)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitStatement(SemanticQueryBuilder.java:449)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.buildSemanticModel(SemanticQueryBuilder.java:322)
at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:71)
at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:145)
at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:132)
at org.hibernate.internal.AbstractSharedSessionContract.interpretHql(AbstractSharedSessionContract.java:802)
at org.hibernate.internal.AbstractSharedSessionContract.interpretAndCreateSelectionQuery(AbstractSharedSessionContract.java:779)
at org.hibernate.internal.AbstractSharedSessionContract.createSelectionQuery(AbstractSharedSessionContract.java:770)
at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createSelectionQuery(TransactionScopedSession.java:1269)
at org.hibernate.engine.spi.SessionLazyDelegator.createSelectionQuery(SessionLazyDelegator.java:744)
at org.hibernate.Session_OpdLahisOZ9nWRPXMsEFQmQU03A_Synthetic_ClientProxy.createSelectionQuery(Unknown Source)
at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.count(CommonPanacheQueryImpl.java:279)
at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.pageCount(CommonPanacheQueryImpl.java:229)
at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.hasNextPage(CommonPanacheQueryImpl.java:219)
at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.hasNextPage(PanacheQueryImpl.java:81)
It seems that this issue is caused by converting the part of the query to lowercase, which is later used in the target query:: String firstSelection = selectMatcher.group(1).trim().toLowerCase(Locale.ROOT);
This string is then used in: countQuery = “SELECT COUNT(” + firstSelection + “) ” + selectMatcher.group(3);
Expected behavior
Method does not modify column name in query
Actual behavior
Metod modify column name in query
How to Reproduce?
Use entity/table with column named in camelCase:
SmeEntity:
@Entity
@Table(name = "some_entity")
public class SomeEntity extends PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
@Column(name = "group_id")
String groupId;
}
Create an HQL query containing a camel case entity field (e.g., groupId) eg.:
PanacheQuery<String> query = SomeEntity.find("select distinct groupId from SomeEntity")
.project(String.class)
.page(Page.ofSize(2));
Call the hasNextPage() method on this query. For example as I did::
boolean doNext;
do {
// some code
doNext = query.hasNextPage();
if (doNext)
query = query.nextPage();
} while (doNext);
Observe the error related to the path expression.
Output of uname -a or ver
MINGW64_NT-10.0-22631 Tytan 3.4.10-87d57229.x86_64 2024-02-14 20:17 UTC x86_64 Msys
Output of java -version
java version "17.0.9" 2023-10-17 LTS Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201) Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)
Quarkus version or git rev
3.12.3
Build tool (ie. output of mvnw --version or gradlew --version)
Gradle 8.3
Additional information
No response
The text was updated successfully, but these errors were encountered:
eKangu
changed the title
SemanticException when use io.quarkus.panache.hibernate.common.runtime.PanacheJpaUtil#getFastCountQuery
Self changes of column names to non-exist column names by PanacheJpaUtil#getFastCountQuery
Jul 25, 2024
@FroMage Any special reason to apply the toLowerCase ? I hit the same bug, makes it impossible to migrate to 3.12
My query SELECT DISTINCT ContractContractEntity FROM ContractContractEntity ... becomes SELECT COUNT(distinct contractcontractentity) FROM ContractContractEntity ... and then Hibernate can no longer find the entity.
Describe the bug
Bug appears in version 3.12.0.CR1 https://github.com/quarkusio/quarkus/releases/tag/3.12.0.CR1
and in all higher versions.
It is likely caused by the change introduced in this pull request:
#38931
, specifically in
io.quarkus.panache.hibernate.common.runtime.PanacheJpaUtil#getFastCountQuery
:d3e578e#diff-88f819be30dca99e30b631c785af5ac15b5ff4b5b91a0ffbace7a5d361ae2b6bR55
When I call the
hasNextPage()
method (io.quarkus.hibernate.orm.panache.PanacheQuery#hasNextPage) on a query in HQL , which contains an entity field with name written in camel case (eg. groupId)), I receive the following error:It seems that this issue is caused by converting the part of the query to lowercase, which is later used in the target query::
String firstSelection = selectMatcher.group(1).trim().toLowerCase(Locale.ROOT);
This string is then used in:
countQuery = “SELECT COUNT(” + firstSelection + “) ” + selectMatcher.group(3);
Expected behavior
Method does not modify column name in query
Actual behavior
Metod modify column name in query
How to Reproduce?
SmeEntity:
Output of
uname -a
orver
MINGW64_NT-10.0-22631 Tytan 3.4.10-87d57229.x86_64 2024-02-14 20:17 UTC x86_64 Msys
Output of
java -version
java version "17.0.9" 2023-10-17 LTS Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201) Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)
Quarkus version or git rev
3.12.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.3
Additional information
No response
The text was updated successfully, but these errors were encountered: