It looks like this will fail in some cases on SQL Server. [1] The obvious workaround is to add the column in the ORDER BY clause as a projection to Projections#distinct. I don't consider this a bug in Hibernate. An improvement would be for Hibernate to add any columns in the ORDER BY clause to the select list if they are not there already. [1] https://msdn.microsoft.com/en-us/library/ms188385.aspx |