Description
HqlParser cannot parse the valid HQL query. Here is the query
SELECT COUNT(f)
FROM FooEntity f
WHERE f.name IN ('Y', 'Basic', 'Remit')
AND f.size = 10
HAVING COUNT(f) > 0
Here is the example https://github.com/afrunt/eql-bug-check
(there are separate profiles for HQL and EQL
mvn clean package -U -P hql
mvn clean package -U -P eql
)
I will add similar upcoming issues to this project if any
NOTE: EqlParser works fine with this case
Caused by: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: At 5:0 and token 'HAVING', mismatched input 'HAVING', expecting one of the following tokens: , ',', '/', '||', '*', AND, BY, DAY, EPOCH, EXCEPT, GROUP, HOUR, INTERSECT, MINUTE, MONTH, NANOSECOND, OR, ORDER, QUARTER, SECOND, UNION, WEEK, YEAR, '+', '-'; Bad HQL grammar [SELECT COUNT(f)
FROM FooEntity f
WHERE f.name IN ('Y', 'Basic', 'Remit')
AND f.size = 10
HAVING COUNT(f) > 0
]
at org.springframework.data.jpa.repository.query.BadJpqlGrammarErrorListener.syntaxError(BadJpqlGrammarErrorListener.java:53) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41) ~[antlr4-runtime-4.13.0.jar:4.13.0]
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544) ~[antlr4-runtime-4.13.0.jar:4.13.0]
at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327) ~[antlr4-runtime-4.13.0.jar:4.13.0]
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139) ~[antlr4-runtime-4.13.0.jar:4.13.0]
at org.springframework.data.jpa.repository.query.HqlParser.start(HqlParser.java:346) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer.parse(JpaQueryEnhancer.java:101) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer$HqlQueryParser.(JpaQueryEnhancer.java:288) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer$HqlQueryParser.parseQuery(JpaQueryEnhancer.java:300) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer.forHql(JpaQueryEnhancer.java:163) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.QueryEnhancerFactory.forQuery(QueryEnhancerFactory.java:68) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.StringQuery.(StringQuery.java:98) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.StringQuery.(StringQuery.java:77) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.ExpressionBasedStringQuery.(ExpressionBasedStringQuery.java:65) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.(AbstractStringBasedJpaQuery.java:84) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.(SimpleJpaQuery.java:65) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:49) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:174) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:254) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:99) ~[spring-data-jpa-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:116) ~[spring-data-commons-3.4.5-SNAPSHOT.jar:3.4.5-SNAPSHOT]
... 110 common frames omitted