dev@glassfish.java.net

Fix for issue 860

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Thu, 27 Jul 2006 11:47:47 -0700
Hi Tom,

attached is a fix for issue 860: Running out of memory--JOINED Inheritance w/ secondary table

The problem is basically that the generated query is missing joins for the tables of the JOINED inheritance, only the join for the secondary table is there.

I modified two classes:

ExpressionBuilder:

moved

>         if (isUsingOuterJoinForMultitableInheritance() && (!getSession().getPlatform().shouldPrintOuterJoinInWhereClause())) {
>             normalizer.getStatement().getOuterJoinExpressions().addElement(null);
>             normalizer.getStatement().getOuterJoinedMappingCriteria().addElement(null);
>             normalizer.getStatement().getOuterJoinedAdditionalJoinCriteria().addElement(additionalExpressionCriteriaMap());
>             normalizer.getStatement().getDescriptorsForMultitableInheritanceOnly().add(this.getDescriptor());
>             // fall through to the main case
...

out of the

        if (!this.wasAdditionJoinCriteriaUsed && this.queryClass != null) {

check. Above lines seems to initiate the addition of joins for the inheritance tables to the query, and should be *always* executed.

SQLSelectStatement:

The secondary table ORDER_SEC is not contained in the Map "tablesJoinExpressions", as this map only contains outer joined tables. So the statement

          Expression onExpression = (Expression)tablesJoinExpressions.get(table);

returns null.

As I'm not totally sure, how outer joins for inheritance and secondary tables are processed by TopLink, this is my best guess of fixing issue 860. It would be great, if somebody for the TopLink team could give me more inside into these two topics. Maybe somebody could educate me over the phone...

With the fix, the correct SQL query is generated, and entity-persistence-tests pass against Derby.

Thanks,

-- markus.