NHibernate HQL Join without returning all required rows
I am modifying an existing HQL query that returns individual columns, not an object graph, but now I am not getting all the rows I need.
Here are some facts about the current scheme:
- The assessment relates to the Contract.
- The OwningDepartment property of the Contract can be null.
- Department ParentBusinessStream property cannot be null
This is the request:
select e.ID, e.StatusCode.ID, e.InputDate, e.ParentClient.Name, e.ParentContractLocation.ParentLocation.Description, e.Description, e.InternalRef, e.ExternalRef, e.TotalIncTax, e.TaxTotal, e.Closed, e.ViewedByClient, e.HelpdeskRef, e.ParentContract.Reference, d.ParentBusinessStream.Title, d.Name
from Estimate e, Department d where (e.ParentContract.ID in (select cs.ParentContract.ID from ContractStaff cs
where cs.ParentStaff.ID=:staffID)) and ((d.ID = e.ParentContract.OwningDepartment.ID) OR (d.ID is null)) order by e.ID
Unfortunately my query does not return Grades where the parent contract does not have an ownership department. Instead, I want the corresponding fields to be zero. I tried left outer join but got the same results.
Any help would be much appreciated. I apologize if I did something stupid.
Greetings,
James
+2
source to share
2 answers