It worked! "datanucleus.query.jdoql.{varName}.join" had to be set to OUTERJOIN for both pt and t. Thanks!
On Sun, Jan 24, 2016 at 2:45 AM, Willie Loyd Tandingan < tandingan....@gmail.com> wrote: > I'm gonna try that one back at work next week. Thanks! > > Admittedly, I thought of that one before but didn't try it out since I > thought it would generate an inner join instead and didn't think of turning > SQL logging on. We tried this erroneous funny query which we thought was > kind of correct but DN didn't accept anyway: > > SELECT this, IF (pt.person == this) THEN pt.template ELSE null FROM Person > p VARIABLES PersonTemplate pt > > I will have to read thoroughly the DN documentation again. > > On Sat, Jan 23, 2016 at 3:36 AM, Andy Jefferson <a...@datanucleus.org> > wrote: > >> On Friday 22 Jan 2016 19:25:24 Andy Jefferson wrote: >> > > > SELECT p.*, t.* FROM Person p >> > > > LEFT JOIN PersonTemplate pt ON p.id = pt.personId >> > > > LEFT JOIN Template t ON pt.templateId = t.id >> > > > >> > > > With this query, I can get Persons even if they don't have a >> Template. >> > > Which is what you would do if you followed the example I suggested, >> using JDOQL variables. >> > > >> > > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.t == t >> > > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t >> > >> > That should be >> > >> > SELECT p, t FROM mydomain.Person WHERE pt.person == this && pt.template >> == t >> > VARIABLES mydomain.PersonTemplate pt, mydomain.Template t >> >> >> Duh, and fixing the Person alias also that should be >> >> SELECT this, t FROM mydomain.Person WHERE pt.person == this && >> pt.template == t >> VARIABLES mydomain.PersonTemplate pt, mydomain.Template t >> >> >> but then its simple if you just try it. >> >> >> -- >> Andy >> DataNucleus (Web: http://www.datanucleus.org Twitter: @datanucleus) >> > >