Consistent NULL order by in Oracle and SQL Server

Hi everyone! We’ve been working with Hibernate for a long time, and it’s working great so far. However, I’ve faced a situation and would like to hear your advice.

We have two custom dialects for Oracle and SQL Server, so that our application deploys for both DBMS. It’s on production for a long time and works great. However, recently we noticed that when sorting, Oracle returns the NULLs first, and SQL Server returns the NULLs last.

Is there any easy/clean way to make both dialects have the same behavior? We are using Hibernate 6.2.13. I think there was something in Hibernate 5, but I haven’t been able to find it in H6.

Thanks a lot and keep up the good work!

Yeah, there is a configuration option to control the default null ordering that Hibernate ORM shall use: hibernate.order_by.default_null_ordering

Lovely, will give it a try. Thanks!