pksiv wrote:
I realize that but do you get any added benefit to joining on fields that aren't part of the key linking the two tables together ? If not, there's no need for the additional ON statements. just use the where clause.
hi there, thank you for your ideas... below is the statement i try to get into hql to work without using the createSQLQuery statement workaround:
SELECT Companies.companyID, Companies.companyParentID, Companies.companyName, 1 AS userCompanyID
FROM Companies
LEFT OUTER JOIN HiddenUserCompanies HiddenUserCompanies ON Companies.companyID = HiddenUserCompanies.companyID AND HiddenUserCompanies.loginUserID = 94
WHERE (Companies.companyParentID=2) AND (HiddenUserCompanies.userCompanyID IS NULL)
ORDER BY Companies.companyName
"Companies" is a table containing companies in a tree-format, "HiddenUserCompanies" is a table containing companies specific users may not be able to view in the tree....
the left join gives me "null"-column values for "userCompanyID" for users having rights to view the tree....
as you stated, i have to probably rewrite my SQL statement to make it HQL compatible... but i dont think that its going to be solved to move the additional condition "AND HiddenUserCompanies.loginUserID = 94
" into the where clause....
sincerely
tvh