================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_prepare_delete_all_query_cleanup_060926/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Report generated at Tue Sep 26 17:34:26 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_prepare_delete_all_query_cleanup_060926/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Tue Sep 26 17:19:13 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Tue Sep 26 17:34:26 2006 *************** *** 926,931 **** --- 926,933 ---- // It's a nested method call: tableInInsertOrder filled with descriptor's tables (in insert order), // the tables found in tablesToIgnore are thrown away - // they have already been taken care of by the caller. + // In Employee example, query with reference class Project gets here + // to handle LPROJECT table; tablesToIgnore contains PROJECT table. tablesInInsertOrder = new Vector(getDescriptor().getMultipleTableInsertOrder().size()); for (Iterator tablesEnum = getDescriptor().getMultipleTableInsertOrder().iterator(); tablesEnum.hasNext();) { *************** *** 1003,1039 **** // In Employee example, query with reference class: // Employee will build "EXISTS" for SALARY and "NOT EXISTS" for EMPLOYEE; ! // LargeProject will build "EXISTS" for LPROJECT and "NOT EXISTS" for Project ! // The situation a more complex if inheritance is involved ! if(!isSelectCallForNotExistRequired) { deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else if (table.equals((DatabaseTable)tablesInInsertOrder.lastElement())) { if(inheritanceExpression == null) { ! // In Employee example, query with reference class: ! // Employee calls this for SALARY table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { ! deleteStatement = buildDeleteAllStatement(table, inheritanceExpression, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); } else { ! ClassDescriptor desc = getHighestDescriptorMappingTable(table); ! if(desc == getDescriptor()) { ! // In Employee example, query with reference class: ! // LargeProject calls this for LPROJECT table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); ! SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, null, null, primaryKeyFields); ! } } - } - } else { - if(inheritanceExpression == null) { - // In Employee example, query with reference class Employee calls this for EMPLOYEE table - deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } else { if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { // This is the highest table in inheritance hierarchy - the one that contains conditions // (usually class indicator fields) that defines the class identity. --- 1005,1041 ---- // In Employee example, query with reference class: // Employee will build "EXISTS" for SALARY and "NOT EXISTS" for EMPLOYEE; ! // LargeProject will build "EXISTS" for LPROJECT and "NOT EXISTS" for Project. ! // The situation is a bit more complex if more than two levels of inheritance is involved: ! // both "EXISTS" and "NOT EXISTS" used for the "intermediate" (not first and not last) tables. ! ! if(tablesToIgnore != null) { ! // isSelectCallForNotExistRequired==false: it's a nested method call. ! // In Employee example, query with reference class ! // Project will get here to handle LPROJECT table ! // Should NOT pass inheritanceExpression - it could only be used with the highest in insertion order table. ! // Because it's a nested call the table can't be first in insertion order. deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else if (tablesInInsertOrder.size() == 1) { ! // isSelectCallForNotExistRequired==false: original call, single table. ! // Handles single table inheritance. If there's no inheritance identical to the one above. ! deleteStatement = buildDeleteAllStatement(table, inheritanceExpression, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! // isSelectCallForNotExistRequired==true: original call, multiple tables. ! ! // indicates whether the table is the last in insertion order ! boolean isLastTable = table.equals((DatabaseTable)tablesInInsertOrder.lastElement()); ! if(inheritanceExpression == null) { ! if(isLastTable) { ! // In Employee example, query with reference class Employee calls this for SALARY table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); } else { ! // In Employee example, query with reference class Employee calls this for EMPLOYEE table ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } } else { + // there is inheritance if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { // This is the highest table in inheritance hierarchy - the one that contains conditions // (usually class indicator fields) that defines the class identity. *************** *** 1043,1054 **** } else { ClassDescriptor desc = getHighestDescriptorMappingTable(table); if(desc == getDescriptor()) { ! // Class has multiple tables that are not inherited. ! // In extended Employee example: ! // Employee2 class inherits from Employee and ! // mapped to two additional tables: EMPLOYEE2 and SALARY2. ! // Query with reference class Employee2 calls this for EMPLOYEE2 table. ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } else { // This table is mapped through descriptor that stands higher in inheritance hierarchy // (but not the highest one - this is taken care in another case). --- 1045,1061 ---- } else { ClassDescriptor desc = getHighestDescriptorMappingTable(table); if(desc == getDescriptor()) { ! if(isLastTable) { ! // In Employee example, query with reference class LargeProject calls this for LPROJECT table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! // Class has multiple tables that are not inherited. ! // In extended Employee example: ! // Employee2 class inherits from Employee and ! // mapped to two additional tables: EMPLOYEE2 and SALARY2. ! // Query with reference class Employee2 calls this for EMPLOYEE2 table. ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); ! } } else { // This table is mapped through descriptor that stands higher in inheritance hierarchy // (but not the highest one - this is taken care in another case). *************** *** 1064,1071 **** // // In extended Employee example: // VeryLargeProject inherits from LargeProject, ! // mapped to an additional table VLPROJECT. ! // Query with reference class VeryLargeProject calls this for LPROJECT table. // // Note that this doesn't work in case LargeProject descriptor was set not to read subclasses: // in that case the selection expression will have (PROJ_TYPE = 'L') AND (PROJ_TYPE = 'V') --- 1071,1079 ---- // // In extended Employee example: // VeryLargeProject inherits from LargeProject, ! // mapped to an additional table VLPROJECT; ! // VeryVeryLargeProject inherits from VeryLargeProject, ! // mapped to the same tables as it's parent. // // Note that this doesn't work in case LargeProject descriptor was set not to read subclasses: // in that case the selection expression will have (PROJ_TYPE = 'L') AND (PROJ_TYPE = 'V') *************** *** 1073,1079 **** SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } } } --- 1081,1096 ---- SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! if(isLastTable) { ! // In extended Employee example: ! // Query with reference class VeryVeryLargeProject calls this for VLPROJECT table. ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, null, null, primaryKeyFields); ! } else { ! // In extended Employee example: ! // Query with reference class VeryLargeProject calls this for LPROJECT table. ! // Note that both EXISTS and NOT EXISTS clauses created. ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); ! } } } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_prepare_delete_all_query_cleanup_060926/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Report generated at Tue Sep 26 17:34:52 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_prepare_delete_all_query_cleanup_060926/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Tue Sep 26 17:19:13 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Tue Sep 26 17:34:26 2006 *************** *** 926,931 **** --- 926,933 ---- // It's a nested method call: tableInInsertOrder filled with descriptor's tables (in insert order), // the tables found in tablesToIgnore are thrown away - // they have already been taken care of by the caller. + // In Employee example, query with reference class Project gets here + // to handle LPROJECT table; tablesToIgnore contains PROJECT table. tablesInInsertOrder = new Vector(getDescriptor().getMultipleTableInsertOrder().size()); for (Iterator tablesEnum = getDescriptor().getMultipleTableInsertOrder().iterator(); tablesEnum.hasNext();) { *************** *** 1003,1039 **** // In Employee example, query with reference class: // Employee will build "EXISTS" for SALARY and "NOT EXISTS" for EMPLOYEE; ! // LargeProject will build "EXISTS" for LPROJECT and "NOT EXISTS" for Project ! // The situation a more complex if inheritance is involved ! if(!isSelectCallForNotExistRequired) { deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else if (table.equals((DatabaseTable)tablesInInsertOrder.lastElement())) { if(inheritanceExpression == null) { ! // In Employee example, query with reference class: ! // Employee calls this for SALARY table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { ! deleteStatement = buildDeleteAllStatement(table, inheritanceExpression, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); } else { ! ClassDescriptor desc = getHighestDescriptorMappingTable(table); ! if(desc == getDescriptor()) { ! // In Employee example, query with reference class: ! // LargeProject calls this for LPROJECT table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); ! SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, null, null, primaryKeyFields); ! } } - } - } else { - if(inheritanceExpression == null) { - // In Employee example, query with reference class Employee calls this for EMPLOYEE table - deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } else { if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { // This is the highest table in inheritance hierarchy - the one that contains conditions // (usually class indicator fields) that defines the class identity. --- 1005,1041 ---- // In Employee example, query with reference class: // Employee will build "EXISTS" for SALARY and "NOT EXISTS" for EMPLOYEE; ! // LargeProject will build "EXISTS" for LPROJECT and "NOT EXISTS" for Project. ! // The situation is a bit more complex if more than two levels of inheritance is involved: ! // both "EXISTS" and "NOT EXISTS" used for the "intermediate" (not first and not last) tables. ! ! if(tablesToIgnore != null) { ! // isSelectCallForNotExistRequired==false: it's a nested method call. ! // In Employee example, query with reference class ! // Project will get here to handle LPROJECT table ! // Should NOT pass inheritanceExpression - it could only be used with the highest in insertion order table. ! // Because it's a nested call the table can't be first in insertion order. deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else if (tablesInInsertOrder.size() == 1) { ! // isSelectCallForNotExistRequired==false: original call, single table. ! // Handles single table inheritance. If there's no inheritance identical to the one above. ! deleteStatement = buildDeleteAllStatement(table, inheritanceExpression, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! // isSelectCallForNotExistRequired==true: original call, multiple tables. ! ! // indicates whether the table is the last in insertion order ! boolean isLastTable = table.equals((DatabaseTable)tablesInInsertOrder.lastElement()); ! if(inheritanceExpression == null) { ! if(isLastTable) { ! // In Employee example, query with reference class Employee calls this for SALARY table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); } else { ! // In Employee example, query with reference class Employee calls this for EMPLOYEE table ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } } else { + // there is inheritance if(table.equals(getDescriptor().getMultipleTableInsertOrder().firstElement())) { // This is the highest table in inheritance hierarchy - the one that contains conditions // (usually class indicator fields) that defines the class identity. *************** *** 1043,1054 **** } else { ClassDescriptor desc = getHighestDescriptorMappingTable(table); if(desc == getDescriptor()) { ! // Class has multiple tables that are not inherited. ! // In extended Employee example: ! // Employee2 class inherits from Employee and ! // mapped to two additional tables: EMPLOYEE2 and SALARY2. ! // Query with reference class Employee2 calls this for EMPLOYEE2 table. ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } else { // This table is mapped through descriptor that stands higher in inheritance hierarchy // (but not the highest one - this is taken care in another case). --- 1045,1061 ---- } else { ClassDescriptor desc = getHighestDescriptorMappingTable(table); if(desc == getDescriptor()) { ! if(isLastTable) { ! // In Employee example, query with reference class LargeProject calls this for LPROJECT table; ! deleteStatement = buildDeleteAllStatement(table, null, selectCallForExist, selectStatementForExist, null, null, primaryKeyFields); ! } else { ! // Class has multiple tables that are not inherited. ! // In extended Employee example: ! // Employee2 class inherits from Employee and ! // mapped to two additional tables: EMPLOYEE2 and SALARY2. ! // Query with reference class Employee2 calls this for EMPLOYEE2 table. ! deleteStatement = buildDeleteAllStatement(table, null, null, null, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); ! } } else { // This table is mapped through descriptor that stands higher in inheritance hierarchy // (but not the highest one - this is taken care in another case). *************** *** 1064,1071 **** // // In extended Employee example: // VeryLargeProject inherits from LargeProject, ! // mapped to an additional table VLPROJECT. ! // Query with reference class VeryLargeProject calls this for LPROJECT table. // // Note that this doesn't work in case LargeProject descriptor was set not to read subclasses: // in that case the selection expression will have (PROJ_TYPE = 'L') AND (PROJ_TYPE = 'V') --- 1071,1079 ---- // // In extended Employee example: // VeryLargeProject inherits from LargeProject, ! // mapped to an additional table VLPROJECT; ! // VeryVeryLargeProject inherits from VeryLargeProject, ! // mapped to the same tables as it's parent. // // Note that this doesn't work in case LargeProject descriptor was set not to read subclasses: // in that case the selection expression will have (PROJ_TYPE = 'L') AND (PROJ_TYPE = 'V') *************** *** 1073,1079 **** SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); } } } --- 1081,1096 ---- SQLSelectStatement inheritanceSelectStatementForExist = createSQLSelectStatementForModifyAll(null, inheritanceExpression, desc); SQLCall inheritanceSelectCallForExist = (SQLCall)inheritanceSelectStatementForExist.buildCall(getSession()); ! if(isLastTable) { ! // In extended Employee example: ! // Query with reference class VeryVeryLargeProject calls this for VLPROJECT table. ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, null, null, primaryKeyFields); ! } else { ! // In extended Employee example: ! // Query with reference class VeryLargeProject calls this for LPROJECT table. ! // Note that both EXISTS and NOT EXISTS clauses created. ! deleteStatement = buildDeleteAllStatement(table, null, inheritanceSelectCallForExist, inheritanceSelectStatementForExist, selectCallForNotExist, selectStatementForNotExist, primaryKeyFields); ! } } } }