-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using CASE statement in order-by (Worked in Hibernate 3.3)
PostPosted: Wed Jun 15, 2011 2:43 pm 
Newbie

Joined: Wed Jun 15, 2011 2:39 pm
Posts: 1
All,

The following order-by in the mapping file worked with Hibernate 3.3 but is not working with the latest version?

order-by="(case when TO_DATE is null then 0 else 1 end), TO_DATE desc, FROM_DATE desc, CREATED_DATE desc, ID desc"

The error being reported is unexpected token: (
Code:
2011-06-15 14:15:14,962 DEBUG [main] (collection.AbstractCollectionPersister:611) - Static SQL for collection: com.jsi.fullcourt.domain.entity.Entity.names
2011-06-15 14:15:14,962 DEBUG [main] (collection.AbstractCollectionPersister:613) - Row insert: update NAME set ENTITY_ID=? where ID=?
2011-06-15 14:15:14,962 DEBUG [main] (collection.AbstractCollectionPersister:619) - Row delete: update NAME set ENTITY_ID=null where ENTITY_ID=? and ID=?
2011-06-15 14:15:14,963 DEBUG [main] (collection.AbstractCollectionPersister:622) - One-shot delete: update NAME set ENTITY_ID=null where ENTITY_ID=?
2011-06-15 14:15:14,963 TRACE [main] (antlr.OrderByFragmentParser:67) - -> orderByFragment
2011-06-15 14:15:14,963 TRACE [main] (antlr.OrderByFragmentParser:82) - orderByFragment
2011-06-15 14:15:14,963 TRACE [main] (antlr.OrderByFragmentParser:67) - ---> sortSpecification
2011-06-15 14:15:14,964 TRACE [main] (antlr.OrderByFragmentParser:82) - sortSpecification
2011-06-15 14:15:14,964 TRACE [main] (antlr.OrderByFragmentParser:67) - -----> sortKey
2011-06-15 14:15:14,964 TRACE [main] (antlr.OrderByFragmentParser:82) - sortKey
2011-06-15 14:15:14,964 TRACE [main] (antlr.OrderByFragmentParser:67) - -------> expression
2011-06-15 14:15:14,965 TRACE [main] (antlr.OrderByFragmentParser:82) - expression
line 1:1: unexpected token: (
2011-06-15 14:15:14,965 TRACE [main] (antlr.OrderByFragmentParser:75) - <------- expression
2011-06-15 14:15:14,965 TRACE [main] (antlr.OrderByFragmentParser:75) - <----- sortKey
line 1:45: unexpected token: )



Any reason why this is no longer supported? Or an alternate syntax?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.