I assume that a is a property of type table_two, and this property is determined by a many-to-one relationship or sth. similarly.
You order by a column that is not a member of the table, but is associated with the table table_two. Sql cannot do this directly, and Hibernate does this by creating a connection between the table and table_two. This join generated by Hibernate is a regular join, not an outer join, so the selection does not retrieve rows that do not have a related record in table_two.
You can solve the problem by specifying an external connection manually. Something like this should work:
FROM table t LEFT OUTER JOIN ta u ORDER BY ub ASC NULLS LAST
source share