openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiaoqin Feng (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-717) OpenJPA doesn't generate SQL with efficient joins when joined inheritance strategy is used and there is one-many relation in superclass
Date Thu, 04 Sep 2008 22:05:45 GMT
OpenJPA doesn't generate SQL with efficient joins when joined inheritance strategy is used
and there is one-many relation in superclass
---------------------------------------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-717
                 URL: https://issues.apache.org/jira/browse/OPENJPA-717
             Project: OpenJPA
          Issue Type: Improvement
          Components: query
    Affects Versions: 1.2.0, 1.1.0, 1.0.3, 1.0.2, 1.0.1, 1.0.0
            Reporter: Xiaoqin Feng


The test case has a subclass that extends an abstract superclass that 
basically contains a single additional field 'S1', a one-to-one relation 'superOne' and a
one-to-many relation 'superMany'. The superclass has an 
inheritance strategy of 'JOINED'. 

When executing the query:

SELECT s FROM Subclass s WHERE s.a1 = :a1

three SQL statements get generated:

SELECT t1.ID, t0.id, t1.S1, t2.ID, t2.S1, t0.A1, t3.ID, t3.A1 
FROM SUBCLASS t0, SUPERCLASS t1, SUPERCLASSONE t2, SUBCLASSONE t3 
WHERE (t0.A1 = ?) AND t0.SUBCLASSONE_ID = t3.ID(+) AND t0.id = t1.ID AND 
t1.SUPERCLASSONE_ID = t2.ID(+)

SELECT t0.id, t1.ID, t1.A1 
FROM SUBCLASS t0, SUBCLASSMANY t1 
WHERE (t0.A1 = ?) AND t0.id = t1.SUBCLASS_ID ORDER BY t0.id ASC

SELECT t1.ID, t2.ID, t2.S1 
FROM SUBCLASS t0, SUPERCLASS t1, SUPERCLASSMANY t2 
WHERE (t0.A1 = ?) AND t1.ID = t2.SUPERCLASS_ID ORDER BY t1.ID ASC

The third one doesn't contain the condition t0.ID = t1.ID

Although final returned result set is correct because of the logical union, the third SQL
returns more rows  so it has bad performance.




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message