================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/databaseaccess/DatabasePlatform.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.26 Report generated at Thu Dec 14 16:30:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.26 Thu Dec 14 15:47:48 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/databaseaccess/DatabasePlatform.java Thu Dec 14 16:30:29 2006 *************** *** 1712,1717 **** --- 1712,1725 ---- /** * INTERNAL: + * Override this if the platform cannot handle NULL in select clause. + */ + public boolean isNullAllowedInSelectClause() { + return true; + } + + /** + * INTERNAL: * May need to override this method if the platform supports temporary tables * and the generated sql doesn't work. * Write an sql string for updating the original table from the temporary table. ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/platform/database/DB2Platform.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Thu Dec 14 16:30:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Thu Dec 14 15:54:11 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/platform/database/DB2Platform.java Thu Dec 14 16:30:29 2006 *************** *** 579,584 **** --- 579,593 ---- return true; } + /** + * INTERNAL: + * Override this if the platform cannot handle NULL in select clause. + */ + public boolean isNullAllowedInSelectClause() { + return false; + } + + public void writeParameterMarker(Writer writer, ParameterExpression parameter) throws IOException { // DB2 requires cast around parameter markers if both operands of certian // operators are parameter markers ================================================================================ 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_gf1451_061214/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.35 Report generated at Thu Dec 14 16:30:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.35 Thu Dec 14 15:59:35 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Thu Dec 14 16:30:29 2006 *************** *** 2094,2115 **** } } SQLUpdateAllStatementForTempTable createTempTableStatement = new SQLUpdateAllStatementForTempTable(); createTempTableStatement.setMode(SQLModifyAllStatementForTempTable.CREATE_TEMP_TABLE); createTempTableStatement.setTable(table); createTempTableStatement.setAllFields(allFields); ! createTempTableStatement.setAssignedFields(databaseFieldsToValues.keySet()); createTempTableStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(createTempTableStatement); ! SQLSelectStatement selectStatement = createSQLSelectStatementForModifyAllForTempTable(databaseFieldsToValues); SQLCall selectCall = (SQLCall)selectStatement.buildCall(getSession()); SQLUpdateAllStatementForTempTable insertStatement = new SQLUpdateAllStatementForTempTable(); insertStatement.setMode(SQLModifyAllStatementForTempTable.INSERT_INTO_TEMP_TABLE); insertStatement.setTable(table); insertStatement.setTranslationRow(getTranslationRow()); insertStatement.setSelectCall(selectCall); ! insertStatement.setAssignedFields(databaseFieldsToValues.keySet()); insertStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(insertStatement); --- 2094,2138 ---- } } + Collection assignedFields = databaseFieldsToValues.keySet(); + HashMap databaseFieldsToValuesForInsert = databaseFieldsToValues; + Collection assignedFieldsForInsert = assignedFields; + + // The platform doesn't allow nulls in select clause. + // Remove all the constant expressions with value null: + // can do that because all fields initialized to null when temp. table created. + if(!getSession().getPlatform().isNullAllowedInSelectClause()) { + databaseFieldsToValuesForInsert = new HashMap(databaseFieldsToValues.size()); + Iterator itEntries = databaseFieldsToValues.entrySet().iterator(); + while(itEntries.hasNext()) { + Map.Entry entry = (Map.Entry)itEntries.next(); + if(entry.getValue() instanceof ConstantExpression) { + ConstantExpression constExp = (ConstantExpression)entry.getValue(); + if(constExp.getValue() == null) { + continue; + } + } + databaseFieldsToValuesForInsert.put(entry.getKey(), entry.getValue()); + } + assignedFieldsForInsert = databaseFieldsToValuesForInsert.keySet(); + } + SQLUpdateAllStatementForTempTable createTempTableStatement = new SQLUpdateAllStatementForTempTable(); createTempTableStatement.setMode(SQLModifyAllStatementForTempTable.CREATE_TEMP_TABLE); createTempTableStatement.setTable(table); createTempTableStatement.setAllFields(allFields); ! createTempTableStatement.setAssignedFields(assignedFields); createTempTableStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(createTempTableStatement); ! SQLSelectStatement selectStatement = createSQLSelectStatementForModifyAllForTempTable(databaseFieldsToValuesForInsert); SQLCall selectCall = (SQLCall)selectStatement.buildCall(getSession()); SQLUpdateAllStatementForTempTable insertStatement = new SQLUpdateAllStatementForTempTable(); insertStatement.setMode(SQLModifyAllStatementForTempTable.INSERT_INTO_TEMP_TABLE); insertStatement.setTable(table); insertStatement.setTranslationRow(getTranslationRow()); insertStatement.setSelectCall(selectCall); ! insertStatement.setAssignedFields(assignedFieldsForInsert); insertStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(insertStatement); *************** *** 2117,2123 **** updateStatement.setMode(SQLModifyAllStatementForTempTable.UPDATE_ORIGINAL_TABLE); updateStatement.setTable(table); updateStatement.setTranslationRow(getTranslationRow()); ! updateStatement.setAssignedFields(databaseFieldsToValues.keySet()); updateStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(updateStatement); --- 2140,2146 ---- updateStatement.setMode(SQLModifyAllStatementForTempTable.UPDATE_ORIGINAL_TABLE); updateStatement.setTable(table); updateStatement.setTranslationRow(getTranslationRow()); ! updateStatement.setAssignedFields(assignedFields); updateStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(updateStatement); ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/databaseaccess/DatabasePlatform.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.26 Report generated at Thu Dec 14 16:31:06 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.26 Thu Dec 14 15:47:48 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/databaseaccess/DatabasePlatform.java Thu Dec 14 16:30:29 2006 *************** *** 1712,1717 **** --- 1712,1725 ---- /** * INTERNAL: + * Override this if the platform cannot handle NULL in select clause. + */ + public boolean isNullAllowedInSelectClause() { + return true; + } + + /** + * INTERNAL: * May need to override this method if the platform supports temporary tables * and the generated sql doesn't work. * Write an sql string for updating the original table from the temporary table. ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/platform/database/DB2Platform.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Thu Dec 14 16:31:06 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Thu Dec 14 15:54:11 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/platform/database/DB2Platform.java Thu Dec 14 16:30:29 2006 *************** *** 579,584 **** --- 579,593 ---- return true; } + /** + * INTERNAL: + * Override this if the platform cannot handle NULL in select clause. + */ + public boolean isNullAllowedInSelectClause() { + return false; + } + + public void writeParameterMarker(Writer writer, ParameterExpression parameter) throws IOException { // DB2 requires cast around parameter markers if both operands of certian // operators are parameter markers ================================================================================ 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_gf1451_061214/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.35 Report generated at Thu Dec 14 16:31:06 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1451_061214/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.35 Thu Dec 14 15:59:35 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Thu Dec 14 16:30:29 2006 *************** *** 2094,2115 **** } } SQLUpdateAllStatementForTempTable createTempTableStatement = new SQLUpdateAllStatementForTempTable(); createTempTableStatement.setMode(SQLModifyAllStatementForTempTable.CREATE_TEMP_TABLE); createTempTableStatement.setTable(table); createTempTableStatement.setAllFields(allFields); ! createTempTableStatement.setAssignedFields(databaseFieldsToValues.keySet()); createTempTableStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(createTempTableStatement); ! SQLSelectStatement selectStatement = createSQLSelectStatementForModifyAllForTempTable(databaseFieldsToValues); SQLCall selectCall = (SQLCall)selectStatement.buildCall(getSession()); SQLUpdateAllStatementForTempTable insertStatement = new SQLUpdateAllStatementForTempTable(); insertStatement.setMode(SQLModifyAllStatementForTempTable.INSERT_INTO_TEMP_TABLE); insertStatement.setTable(table); insertStatement.setTranslationRow(getTranslationRow()); insertStatement.setSelectCall(selectCall); ! insertStatement.setAssignedFields(databaseFieldsToValues.keySet()); insertStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(insertStatement); --- 2094,2138 ---- } } + Collection assignedFields = databaseFieldsToValues.keySet(); + HashMap databaseFieldsToValuesForInsert = databaseFieldsToValues; + Collection assignedFieldsForInsert = assignedFields; + + // The platform doesn't allow nulls in select clause. + // Remove all the constant expressions with value null: + // can do that because all fields initialized to null when temp. table created. + if(!getSession().getPlatform().isNullAllowedInSelectClause()) { + databaseFieldsToValuesForInsert = new HashMap(databaseFieldsToValues.size()); + Iterator itEntries = databaseFieldsToValues.entrySet().iterator(); + while(itEntries.hasNext()) { + Map.Entry entry = (Map.Entry)itEntries.next(); + if(entry.getValue() instanceof ConstantExpression) { + ConstantExpression constExp = (ConstantExpression)entry.getValue(); + if(constExp.getValue() == null) { + continue; + } + } + databaseFieldsToValuesForInsert.put(entry.getKey(), entry.getValue()); + } + assignedFieldsForInsert = databaseFieldsToValuesForInsert.keySet(); + } + SQLUpdateAllStatementForTempTable createTempTableStatement = new SQLUpdateAllStatementForTempTable(); createTempTableStatement.setMode(SQLModifyAllStatementForTempTable.CREATE_TEMP_TABLE); createTempTableStatement.setTable(table); createTempTableStatement.setAllFields(allFields); ! createTempTableStatement.setAssignedFields(assignedFields); createTempTableStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(createTempTableStatement); ! SQLSelectStatement selectStatement = createSQLSelectStatementForModifyAllForTempTable(databaseFieldsToValuesForInsert); SQLCall selectCall = (SQLCall)selectStatement.buildCall(getSession()); SQLUpdateAllStatementForTempTable insertStatement = new SQLUpdateAllStatementForTempTable(); insertStatement.setMode(SQLModifyAllStatementForTempTable.INSERT_INTO_TEMP_TABLE); insertStatement.setTable(table); insertStatement.setTranslationRow(getTranslationRow()); insertStatement.setSelectCall(selectCall); ! insertStatement.setAssignedFields(assignedFieldsForInsert); insertStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(insertStatement); *************** *** 2117,2123 **** updateStatement.setMode(SQLModifyAllStatementForTempTable.UPDATE_ORIGINAL_TABLE); updateStatement.setTable(table); updateStatement.setTranslationRow(getTranslationRow()); ! updateStatement.setAssignedFields(databaseFieldsToValues.keySet()); updateStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(updateStatement); --- 2140,2146 ---- updateStatement.setMode(SQLModifyAllStatementForTempTable.UPDATE_ORIGINAL_TABLE); updateStatement.setTable(table); updateStatement.setTranslationRow(getTranslationRow()); ! updateStatement.setAssignedFields(assignedFields); updateStatement.setPrimaryKeyFields(primaryKeyFields); statements.addElement(updateStatement);