HQL grammar does not actually support the CASE statement
--------------------------------------------------------
Key: HHH-3631
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3631
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1 ga, Postgresql
Reporter: Andra Nedelcovici
Using a simple form of the CASE statement in HQL like the following
from EnumerationValue where enumeration = 'XXX' and (case :param
when 1 then value > 5
when 2 then value < 100
else true
end) order by id
yields
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: case near line 1, column
54 [...]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:258)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650) ...
I also tried this (silly, isn't it?):
from EnumerationValue where enumeration = 'XXX' and (1=1 and case 3
when 1 then false
when 2 then true
else true
end) order by id
in order to check for HQL grammar limitations, but the result is just the same.
I should also mention that I ran successfully the above queries in a PostgreSQL console
(with the normal adjustments).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira