We have a JPQL query that is like this:

SELECT COUNT(s.id) FROM SubsidiaryDetail s
JOIN s.accountEntry a
JOIN a.journalEntry j
WHERE j.id = :journalEntryId
AND s.amount <> 0
AND TYPE(s) NOT IN (ARSubsidiaryDetail)


As you can hopefully see SubsidiaryDetail is a supertype;
ARSubsidiaryDetailis a subtype.  So far so good.  The (mysterious) SQL
that comes out of
OpenJPA 2.2.1 is:

SELECT *t3.id*, COUNT(t0.id)
FROM ngp.subsidiary_detail t0
INNER JOIN ngp.account_entry t1 ON t0.account_entry_id = t1.id
INNER JOIN ngp-journal_entry t2 ON t1.journal_entry_id = t2.id,
*ngp.ar_subsidiary_detail t3* // <---- this is suspect; no join?
WHERE (t1.journal_entry_id = ? AND t0.amount <> ? AND t0.DTYPE = 'AR' AND 1
= 1)


Note line 5, which appears to be inserting the subtype table as another
element of the FROM clause, not as an INNER JOIN.  Note as well that
this t3alias then shows up in the
SELECT clause.

Where do I begin untangling this?

Best,
Laird

-- 
http://about.me/lairdnelson

Reply via email to