|
|
|
not really a backward compatibility, more a bug based misuse
Would two additional overloaded methods such as the following be appropriate? The developer could use the database default ordering by using the existing API or attempt to specify the preference if the underlying database supports the clause. Would Hibernate's dialect functionality could help with the platform-related issues?
In org.hibernate.criterion.Order: public static Order asc(String propertyName, NullPrecedence nullPrecedence) public static Order desc(String propertyName, NullPrecedence nullPrecedence) And add a NullPrecedence enumeration with NULLS_FIRST and NULLS_LAST constants. For databases that don't support it, you can do: order by -colum DESC when you mean order by column ASC
This will reverse the order. Do you have any idea about when this issue is going to be implemented?
We are working on a large project using Hibernate, and really would like to see this issue fixed.
I do not have problem in using some oracle native functions in order by clause in HQL except "NULLS LAST". Hibernate while generating oracle sql ignoring th key word (NULLS LAST) and generating the SQL without the keyword present in order by clause. Following is a sample query i am using HQL: " select me.name from MyEntity me order by me.name NULLS LAST" generated SQL: select TBL.NAME FROM MyTable TBL ORDER BY TBL.NAME. Thanks Sridhar "We are working on a large project using Hibernate, and really would like to see this issue fixed."
So either provide a patch or consider commercial support Oracle dialect:
- "property asc nulls first" - "property desc nulls first" - "property asc nulls last" - "property desc nulls last" MySQL dialect: use the minus sign trick - "property asc" - "-property asc" = desc nulls first - "-property desc" = asc nulls last - "property desc" Just FYI: PostgreSQL supports nulls last/first starting from 8.3 version.
http://postgresql.com.cn/docs/8.3/static/queries-order.html (compare with http://postgresql.com.cn/docs/8.2/static/queries-order.html) Cheers, In the meantime fell free to use this interceptor.
Thanks for the Interceptor Emilio but you missed two important cases.
You have to watch our for 'limit' statements if paging is used and also for functions upper(column_name) |
||||||||||||||||||||||||||||||||||||||||||||||||||
In Hibernate 2 'nulls first' segment was copied as is to the generated SQL. In Hibernate 3 it is ommitted.