/** * @param databaseTableDescription - table for columns actually in the database * @param configColumns - column names of configurated columns */ private void checkUnknownColumns( TableDescription databaseTableDescription, String[] configColumns) { Collection<String> c = getUnmappedColumns(databaseTableDescription.getTableName()); String[] unmappedColumns = c.toArray(new String[0]); // check that unmapped columns exist in database for (String unmapped : c) { assertTrue( "Column: " + databaseTableDescription.getTableName() + "." + unmapped + " [declared as unknown, but] not in database", databaseTableDescription.getColumn(unmapped) != null); } String[] dbColumns = databaseTableDescription.getColumnNames(); for (String theDbColumn : dbColumns) { if (!containsIgnoreCase(unmappedColumns, theDbColumn)) { assertTrue( "Table " + databaseTableDescription.getTableName() + " contains unknown column: '" + theDbColumn + "'", containsIgnoreCase(configColumns, theDbColumn)); } } }
/** * configuration - declare a column as not mapped in the database, so that it will not be treated * as an error during assertSchemaComplete(). * * @param tableName * @param columnName */ public void addUnmappedColumn(String tableName, String columnName) { Collection c = (Collection) getUnmappedColumns().get(tableName.toUpperCase()); if (c == null) { c = new HashSet(); getUnmappedColumns().put(tableName.toUpperCase(), c); } c.add(columnName); }