QuerySyntaxException when use CriteriaBuilder.concat in selectCase expression

Description

Using concat inside a case clause leads to QuerySyntaxException: unexpected token: ||

1 2 3 4 5 6 CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<SomeEntity> c = cb.createQuery(SomeEntity.class); Root<SomeEntity> r = c.from(SomeEntity.class); c.multiselect(cb.selectCase().when(cb.isNotNull(r.get("someprop")), cb.concat("A", "B")) .otherwise(cb.concat("C", "D")))); ....

It compiles in HQL like:

1 select case when generatedAlias0.someprop is not null then 'A' || 'B' else 'C' || 'D' end from SomeEntity as generatedAlias0

It looks like 'A' || 'B' expression should be wrapped with brackets, while using HQL directly with wrapped value(i.e. ('A' || 'B')) works properly.

Environment

None

Status

Assignee

Andrea Boriero

Reporter

Nikita Metzger

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.1.0
5.0.9
5.2.0

Priority

Major