The issue I have is that I try to order by a property in an associated object (composite pattern). Thus I have a class PreApprovalRequest and a property in that class assignedTo of type PaceUser. I am trying to order requests by the name of the assignedTo user.
Concrete code below. I have a call that loads all PreApprovalRequest objects (for simplicity I'll leave out pagination). E.g.
That translates to:
Now, when I apply the ordering by first name and then last name of the assignedTo user, the query translates into:
Note that because the join used when applying sorting is the default one (not using the JOIN keyword) - which is basically INNER JOIN - the items where there is no user assigned to the request will be filtered out, which is not desired of course.
Thus, I think the solution is to join using LEFT OUTER JOIN instead of default join and that should fix it.
I'm happy to clone the repository and add the fix if needed.