Hi,
Iam migrating a big project from MSSQL to Postgres and I have issues with the ordering of null values. The order by nulls behaviour is inverse between these two RDBMS. In postgres the sorting of nulls is:
By default, null values sort as if larger than any non-null value; that is,
NULLS FIRSTis the default forDESCorder, andNULLS LASTotherwise.
And in MSSQL:
ASCsorts from the lowest value to highest value.DESCsorts from highest value to lowest value.ASCis the default sort order.NULLvalues are treated as the lowest possible values.
I have a lot of integration tests that test exactly this behaviour and I would like to keep them as their are. In Hibernate I can set the hibernate.order_by.default_null_ordering to either first or last but this is not the same as my desired behaviour.
This Stackoverflow suggests implemeting some weird interceptor to solve this issue. Furthermore there is the Idea to extend the PostgreSQL10Dialect (which apparently dose not exist anlymore) to have this functionallity baked into hibernate directly. But I can’t find the method renderOrderByElement anywere in Hibernate 6.
What whould you suggest to do?
What is the best solution for this problem?
Shouldn’t there be a native option in hibernate to allow the seamless use of thoses RDBMS?