This issue has been reported in a different context before. Here's my problem:
I have the following annotation:
Code:
@org.hibernate.annotations.OrderBy(clause="case when displayOrder is null then 1 else null end, displayOrder, displayOrder, category_name")
which works well in hibernate-annotations 3.4.0.GA and with a MySQL DB.
After upgrading to 3.5.6-Final (I've also tried 3.5.0.Final) I'm getting the exception "Failed to create session factory: Unable to parse order-by fragment".
The root cause appears to be the 'case' keyword:
Code:
00:09:58,067 TRACE sql.ordering.antlr.OrderByFragmentParser:67 - -> orderByFragment
00:09:58,070 TRACE sql.ordering.antlr.OrderByFragmentParser:82 - orderByFragment
00:09:58,071 TRACE sql.ordering.antlr.OrderByFragmentParser:67 - ---> sortSpecification
00:09:58,071 TRACE sql.ordering.antlr.OrderByFragmentParser:82 - sortSpecification
00:09:58,072 TRACE sql.ordering.antlr.OrderByFragmentParser:67 - -----> sortKey
00:09:58,073 TRACE sql.ordering.antlr.OrderByFragmentParser:82 - sortKey
00:09:58,074 TRACE sql.ordering.antlr.OrderByFragmentParser:67 - -------> expression
00:09:58,074 TRACE sql.ordering.antlr.OrderByFragmentParser:82 - expression
line 1:1: unexpected token: case
00:09:58,080 TRACE sql.ordering.antlr.OrderByFragmentParser:75 - <------- expression
00:09:58,089 TRACE sql.ordering.antlr.OrderByFragmentParser:75 - <----- sortKey
00:09:58,091 TRACE sql.ordering.antlr.OrderByFragmentParser:75 - <--- sortSpecification
00:09:58,092 TRACE sql.ordering.antlr.OrderByFragmentParser:75 - <- orderByFragment
Is there any way out of this? I need this order statement to get null values sorted at the end instead of at the beginning.
Is there a reason why 'case' is not accepted any more,or should I file a bug?
Thank you for any advise.