CASE WHEN ... THEN ... END in @OrderBy annotation throws exception: unexpected token: CASE

Description

Here are the table mappings:

Club entity:

Team entity:

A club has multiple teams, nothing special.

Note the `@OrderBy` annotation to sort the list. Sort logic in human language: if "over" then by age group ascending, if under by age group descending, then by gender DESC, then by ordinal nbr

This fails with an exception:

According to https://stackoverflow.com/questions/31701286/how-to-use-case-when-in-jpa this can/should work.

I've been asking this question on SO BTW here: https://stackoverflow.com/questions/59587201/jpa-hibernate-case-in-orderby-annotation-throws-exception-unexpected-token-ca

I will try to get a test case ready, hopefully right with a PR.

Environment

Hibernate 5.3.6.Final, also tested with 5.4.10.Final, MySQL 8, HSQLDB, Java 8, WildFly 14.0.1.Final

Assignee

Unassigned

Reporter

Ka Wu

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure