Uploaded image for project: 'Hibernate ORM'
  1. HHH-10843

QuerySyntaxException when use CriteriaBuilder.concat in selectCase expression

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

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

      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:

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: