cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Dyadych (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CAY-1712) Generate LEFT OUTER join instead of INNER one when selecting via base class
Date Sat, 09 Jun 2012 12:44:43 GMT
Pavel Dyadych created CAY-1712:
----------------------------------

             Summary: Generate LEFT OUTER join instead of INNER one when selecting via base
class
                 Key: CAY-1712
                 URL: https://issues.apache.org/jira/browse/CAY-1712
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.0.2
            Reporter: Pavel Dyadych


I have the same problem as here: http://cayenne.195.n3.nabble.com/Problem-querying-vertical-inheritance-tp3486975.html

The idea is that then having more when one derived class for a base class and trying to query
base class - you get nothing, because improper SQL query is built:

SELECT t0.TYPE, t1.BAR, t2.FOO, t0.ID FROM ITEM t0 JOIN ITEM_BAR t1 ON (t0.ID = t1.ID) JOIN
ITEM_FOO t2 ON (t0.ID = t2.ID)

instead of:

SELECT t0.TYPE, t1.BAR, t2.FOO, t0.ID FROM ITEM t0 LEFT JOIN ITEM_BAR t1 ON (t0.ID = t1.ID)
LEFT JOIN ITEM_FOO t2 ON (t0.ID = t2.ID)

Looks like in org."apache.cayenne.access.trans.SelectTranslator#appendQueryColumns" when checking
"pathPart" if it is instance of "DbRelationship" there should be also a check for depPK. I
mean instead of:

...
else if (pathPart instanceof DbRelationship) {
    DbRelationship rel = (DbRelationship) pathPart;
    dbRelationshipAdded(rel, JoinType.INNER, null);
}

there should be something like

...
else if (pathPart instanceof DbRelationship) {
    DbRelationship rel = (DbRelationship) pathPart;
    dbRelationshipAdded(rel, rel.isToDependentPK() ? JoinType.LEFT_OUTER : JoinType.INNER,
null);
}

This case, when you perform SelectQuery(Item.class) - you get all the instances of all subclasses
of Item.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message