The right outer join in your query doesn't make a whole lot of sense since you are doing a distinct and only selecting the values from o.*
The right join will get all the rows where the two tables join on position_id, and all the other rows that are just in position/transaction. When the rows are only in position or transaction, the values for the order columns will be null. When the distinct is done, these will all be comibined into one row of null values.
I think this query will get you the same results, without the one row of null values:
SELECT DISTINCT o FROM Orders o JOIN o.position p WHERE p.createdAt > :date UNION SELECT DISTINCT o FROM Orders o JOIN o.transaction t WHERE t.transactionClose > :date UNION SELECT DISTINCT o FROM Orders o WHERE o.createdAt > :date
|