oracle - how to apply NULLS LAST sorting in Grails/GORM -


i'm using grails detachedcriteria query, , need null values ordered last when sorting descending. against oracle database.

based on research i've done far, there no direct support in hibernate, , hence not in grails:

grails/hibernate: how order isnull(property) nulls last?

and

https://hibernate.atlassian.net/browse/hhh-2381

based on these, seems best option extend order class hibernate , add nulls last support myself. following path, can give me example of how exposed through grails? have little experience straight hibernate, examples given rather difficult follow.

alternatively: there way in oracle specify nulls last sorting within table definition, via property on column or like?

following example in grails criteria sort nulls @ last overriding hibernate addorder method

def usercriteria = user.createcriteria() list results = usercriteria.list(max:limit, offset:offset) {     eq("isactive", true)     ilike("firstname",text+"%")     usercriteria.addorder(order.asc("firstname").nulls(nullprecedence.last)); } 

you can have in or block. eg.

or{     usercriteria.addorder(order.asc(username).nulls(nullprecedence.last));     usercriteria.addorder(order.asc(email).nulls(nullprecedence.last));     usercriteria.addorder(order.asc(first_name).nulls(nullprecedence.last));     usercriteria.addorder(order.asc(last_name).nulls(nullprecedence.last)); } 

hope helps searching me.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -