I am trying to perform a query in grails that orders by multiple columns, however this does not appear to be working against a SQL Server database (works fine against Oracle).
def criteria = DomainObject.createCriteria()
results = criteria.list() {
or {
eq("field", valueA)
eq("field", valueB)
}
order("field", "asc")
order("lastUpdated", "desc")
}
I have attempted to put the ordering inside an ‘and’ clause.
UPDATE: It would appear that my problem is not due to the failure of multiple column order, but instead the way that NULL values are represented by Oracle and SQL Server when ordering. With “asc” NULLS come first on SQL Server, but last on Oracle.
I think I am going to need to do some post processing (sorting) on the returned grails list, but if anyone has better ideas that would be appreciated.
Any help is appreciated.
Thanks
I went a separate way of using multiple tables, so the NULL values were not causing any issues as there didnt seem to be any simple solution.
However the Hibernate Issue 465 (linked above) appears to have been fixed now:
http://in.relation.to/Bloggers/HibernateORM420CR1Released