Document how to use arithmetic expressions in CASE statements

Description

When writing an HQL query like this one:

1 select case when p.name = 'Steve' then p.id * 10 else p.id end from Person p order by p.id

We get the following exception thrown:

1 2 3 4 5 6 7 8 9 10 11 Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: * near line 1, column 45 [select case when p.name = 'Steve' then p.id * 10 else p.id end from org.hibernate.test.hql.CaseStatementTest$Person p order by p.id] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) at org.hibernate.hql.internal.ast.ErrorTracker.throwQueryException(ErrorTracker.java:93) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:297) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:118) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:78) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:158) at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:595) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:704)

The problem is caused by the * operator in this example.

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Vlad Mihalcea

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.3.7

Priority

Major
Configure