Last week we discussed navigating through references and specifically the
following:
SELECT this from Employee where manager.manager == null
This translates to:
SELECT DISTINCT
A0.BIRTHDATE,A0.FIRSTNAME,A0.LASTNAME,A0.PERSONID,A0.HIREDATE,A0.WEEKLYHOURS,A0.DISCRIMINATOR
FROM APPLICATIONIDENTITY0.PERSONS A0
LEFT OUTER JOIN APPLICATIONIDENTITY0.PERSONS B0 ON A0.MANAGER = B0.PERSONID
WHERE ((A0.DISCRIMINATOR = 'org.apache.jdo.tck.pc.company.FullTimeEmployee’
OR A0.DISCRIMINATOR = 'org.apache.jdo.tck.pc.company.PartTimeEmployee'))
AND B0.MANAGER IS NULL
Navigation through a null-valued field, which would throw NullPointerException,
is treated as if the subexpression returnedfalse. Similarly, a failed cast
operation, which would throw ClassCastException, is treated as if the
subexpression returned false. Other subexpressions or [other values for
variables might still qualify the candidate instance for inclusion in the
result set.]
The above SQL does not implement this JDOQL specification.
The problem is that the WHERE condition B0.MANAGER IS NULL it true for two
distinct cases:
o B0 is null
o B0 is not null and B0.manager is null
In order for the B0.manager == null to return only cases where B0 is not null
and B0.manager is null, the SQL would have to do one of these:
o include AND A0.MANAGER IS NOT NULL
o use INNER JOIN APPLICATIONIDENTITY0.PERSONS B0 ON A0.MANAGER = B0.PERSONID
It is not clear to me that LEFT OUTER JOIN is appropriate here.
Craig L Russell
Architect
[email protected]
P.S <mailto:[email protected]>. A good JDO? O, Gasp!