Java Code Examples for org.apache.ddlutils.model.Table#getIndex()
The following examples show how to use
org.apache.ddlutils.model.Table#getIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AxionModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ protected void removeSystemIndices(DatabaseMetaDataWrapper metaData, Table table) throws SQLException { // Axion's JDBC driver does not support primary key reading, so we have to filter at this level for (int indexIdx = 0; indexIdx < table.getIndexCount();) { Index index = table.getIndex(indexIdx); // also, Axion's internal indices are not unique if (index.getName().startsWith("SYS_")) { table.removeIndex(indexIdx); } else { indexIdx++; } } }
Example 2
Source File: JdbcModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Tries to remove the internal index for the table's primary key. * * @param metaData The database meta data * @param table The table */ protected void removeInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table) throws SQLException { Column[] pks = table.getPrimaryKeyColumns(); List columnNames = new ArrayList(); for (int columnIdx = 0; columnIdx < pks.length; columnIdx++) { columnNames.add(pks[columnIdx].getName()); } for (int indexIdx = 0; indexIdx < table.getIndexCount();) { Index index = table.getIndex(indexIdx); if (index.isUnique() && matches(index, columnNames) && isInternalPrimaryKeyIndex(metaData, table, index)) { table.removeIndex(indexIdx); } else { indexIdx++; } } }
Example 3
Source File: JdbcModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Tries to remove the internal index for the table's primary key. * * @param metaData The database meta data * @param table The table */ protected void removeInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table) throws SQLException { Column[] pks = table.getPrimaryKeyColumns(); List columnNames = new ArrayList(); for (int columnIdx = 0; columnIdx < pks.length; columnIdx++) { columnNames.add(pks[columnIdx].getName()); } for (int indexIdx = 0; indexIdx < table.getIndexCount();) { Index index = table.getIndex(indexIdx); if (index.isUnique() && matches(index, columnNames) && isInternalPrimaryKeyIndex(metaData, table, index)) { table.removeIndex(indexIdx); } else { indexIdx++; } } }
Example 4
Source File: AxionModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ protected void removeSystemIndices(DatabaseMetaDataWrapper metaData, Table table) throws SQLException { // Axion's JDBC driver does not support primary key reading, so we have to filter at this level for (int indexIdx = 0; indexIdx < table.getIndexCount();) { Index index = table.getIndex(indexIdx); // also, Axion's internal indices are not unique if (index.getName().startsWith("SYS_")) { table.removeIndex(indexIdx); } else { indexIdx++; } } }
Example 5
Source File: MSSqlModelReader.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException { String tableName = (String)values.get("TABLE_NAME"); for (int idx = 0; idx < KNOWN_SYSTEM_TABLES.length; idx++) { if (KNOWN_SYSTEM_TABLES[idx].equals(tableName)) { return null; } } Table table = super.readTable(metaData, values); if (table != null) { // Sql Server does not return the auto-increment status via the database metadata determineAutoIncrementFromResultSetMetaData(table, table.getColumns()); // TODO: Replace this manual filtering using named pks once they are available // This is then probably of interest to every platform for (int idx = 0; idx < table.getIndexCount();) { Index index = table.getIndex(idx); if (index.isUnique() && existsPKWithName(metaData, table, index.getName())) { table.removeIndex(idx); } else { idx++; } } } return table; }
Example 6
Source File: SqlBuilder.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Writes the indexes for the given table using external index creation statements. * * @param table The table */ public void createIndexes(Table table) throws IOException { for (int idx = 0; idx < table.getIndexCount(); idx++) { Index index = table.getIndex(idx); if (!index.isUnique() && !getPlatformInfo().isIndicesSupported()) { throw new ModelException("Platform does not support non-unique indices"); } createIndex(table, index); } }
Example 7
Source File: ModelComparator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Searches in the given table for a corresponding index. If the given index * has no name, then a index to the same table with the same columns in the * same order is searched. If the given index has a name, then the a corresponding * index also needs to have the same name, or no name at all, but not a different one. * * @param table The table to search in * @param index The original index * @return The corresponding index if found */ protected Index findCorrespondingIndex(Table table, Index index) { for (int indexIdx = 0; indexIdx < table.getIndexCount(); indexIdx++) { Index curIndex = table.getIndex(indexIdx); if ((_caseSensitive && index.equals(curIndex)) || (!_caseSensitive && index.equalsIgnoreCase(curIndex))) { return curIndex; } } return null; }
Example 8
Source File: SqlBuilder.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Writes the indexes for the given table using external index creation statements. * * @param table The table */ public void createIndexes(Table table) throws IOException { for (int idx = 0; idx < table.getIndexCount(); idx++) { Index index = table.getIndex(idx); if (!index.isUnique() && !getPlatformInfo().isIndicesSupported()) { throw new ModelException("Platform does not support non-unique indices"); } createIndex(table, index); } }
Example 9
Source File: ModelComparator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Creates change objects for indexes that are not present in the given source table but are in the target * table, and applies them to the given intermediate model. * * @param sourceModel The source model * @param sourceTable The source table * @param intermediateModel The intermediate model to apply the changes to * @param intermediateTable The table from the intermediate model corresponding to the source table * @param targetModel The target model * @param targetTable The target table * @return The changes */ protected List checkForAddedIndexes(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable) { List changes = new ArrayList(); for (int indexIdx = 0; indexIdx < targetTable.getIndexCount(); indexIdx++) { Index targetIndex = targetTable.getIndex(indexIdx); Index intermediateIndex = findCorrespondingIndex(intermediateTable, targetIndex); Index sourceIndex = findCorrespondingIndex(sourceTable, targetIndex); if ((sourceIndex == null) && (intermediateIndex == null)) { if (_log.isInfoEnabled()) { _log.info("Index " + targetIndex.getName() + " needs to be created for table " + intermediateTable.getQualifiedName()); } Index clonedIndex = _cloneHelper.clone(targetIndex, intermediateTable, _caseSensitive); AddIndexChange change = new AddIndexChange(intermediateTable.getQualifiedName(), clonedIndex); changes.add(change); change.apply(intermediateModel, _caseSensitive); } } return changes; }
Example 10
Source File: JdbcModelReader.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Tries to remove the internal index for the given foreign key. * * @param metaData The database meta data * @param table The table where the table is defined * @param fk The foreign key */ protected void removeInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table, ForeignKey fk) throws SQLException { List columnNames = new ArrayList(); boolean mustBeUnique = !getPlatformInfo().isSystemForeignKeyIndicesAlwaysNonUnique(); for (int columnIdx = 0; columnIdx < fk.getReferenceCount(); columnIdx++) { String name = fk.getReference(columnIdx).getLocalColumnName(); Column localColumn = table.findColumn(name, getPlatform().isDelimitedIdentifierModeOn()); if (mustBeUnique && !localColumn.isPrimaryKey()) { mustBeUnique = false; } columnNames.add(name); } for (int indexIdx = 0; indexIdx < table.getIndexCount();) { Index index = table.getIndex(indexIdx); if ((!mustBeUnique || index.isUnique()) && matches(index, columnNames) && isInternalForeignKeyIndex(metaData, table, fk, index)) { fk.setAutoIndexPresent(true); table.removeIndex(indexIdx); } else { indexIdx++; } } }
Example 11
Source File: ModelComparator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Searches in the given table for a corresponding index. If the given index * has no name, then a index to the same table with the same columns in the * same order is searched. If the given index has a name, then the a corresponding * index also needs to have the same name, or no name at all, but not a different one. * * @param table The table to search in * @param index The original index * @return The corresponding index if found */ protected Index findCorrespondingIndex(Table table, Index index) { for (int indexIdx = 0; indexIdx < table.getIndexCount(); indexIdx++) { Index curIndex = table.getIndex(indexIdx); if ((_caseSensitive && index.equals(curIndex)) || (!_caseSensitive && index.equalsIgnoreCase(curIndex))) { return curIndex; } } return null; }
Example 12
Source File: ModelComparator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Creates change objects for indexes that are not present in the given source table but are in the target * table, and applies them to the given intermediate model. * * @param sourceModel The source model * @param sourceTable The source table * @param intermediateModel The intermediate model to apply the changes to * @param intermediateTable The table from the intermediate model corresponding to the source table * @param targetModel The target model * @param targetTable The target table * @return The changes */ protected List checkForAddedIndexes(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable) { List changes = new ArrayList(); for (int indexIdx = 0; indexIdx < targetTable.getIndexCount(); indexIdx++) { Index targetIndex = targetTable.getIndex(indexIdx); Index intermediateIndex = findCorrespondingIndex(intermediateTable, targetIndex); Index sourceIndex = findCorrespondingIndex(sourceTable, targetIndex); if ((sourceIndex == null) && (intermediateIndex == null)) { if (_log.isInfoEnabled()) { _log.info("Index " + targetIndex.getName() + " needs to be created for table " + intermediateTable.getQualifiedName()); } Index clonedIndex = _cloneHelper.clone(targetIndex, intermediateTable, _caseSensitive); AddIndexChange change = new AddIndexChange(intermediateTable.getQualifiedName(), clonedIndex); changes.add(change); change.apply(intermediateModel, _caseSensitive); } } return changes; }
Example 13
Source File: IndexChangeImplBase.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Index findChangedIndex(Database model, boolean caseSensitive) { Table table = findChangedTable(model, caseSensitive); if (table != null) { for (int indexIdx = 0; indexIdx < table.getIndexCount(); indexIdx++) { Index curIndex = table.getIndex(indexIdx); if (curIndex.getColumnCount() == _columnNames.size()) { for (int colIdx = 0; colIdx < curIndex.getColumnCount(); colIdx++) { String curColName = curIndex.getColumn(colIdx).getName(); String expectedColName = (String)_columnNames.get(colIdx); if ((caseSensitive && curColName.equals(expectedColName)) || (!caseSensitive && curColName.equalsIgnoreCase(expectedColName))) { return curIndex; } } } } } return null; }
Example 14
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an index with two columns. */ public void testIndexWithTwoColumns() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='when'\n" + " type='TIMESTAMP'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <index>\n" + " <index-column name='when'/>\n" + " <index-column name='id'/>\n" + " </index>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 3, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("when", Types.TIMESTAMP, 0, 0, null, null, null, false, true, false, table.getColumn(1)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(2)); Index index = table.getIndex(0); assertEquals(null, false, 2, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals(table.getColumn(0), null, index.getColumn(1)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"when\" primaryKey=\"false\" required=\"true\" type=\"TIMESTAMP\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <index>\n" + " <index-column name=\"when\" />\n" + " <index-column name=\"id\" />\n" + " </index>\n" + " </table>\n" + "</database>\n", model); }
Example 15
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an index with a name. */ public void testIndexWithName() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <index name='The Index'>\n" + " <index-column name='value'/>\n" + " </index>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 2, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(1)); Index index = table.getIndex(0); assertEquals("The Index", false, 1, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <index name=\"The Index\">\n" + " <index-column name=\"value\" />\n" + " </index>\n" + " </table>\n" + "</database>\n", model); }
Example 16
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an index. */ public void testSingleIndex() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <index>\n" + " <index-column name='value'/>\n" + " </index>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 2, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(1)); Index index = table.getIndex(0); assertEquals(null, false, 1, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <index>\n" + " <index-column name=\"value\" />\n" + " </index>\n" + " </table>\n" + "</database>\n", model); }
Example 17
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an unique index with two columns. */ public void testUniqueIndexWithTwoColumns() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='when'\n" + " type='TIMESTAMP'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <unique>\n" + " <unique-column name='when'/>\n" + " <unique-column name='id'/>\n" + " </unique>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 3, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("when", Types.TIMESTAMP, 0, 0, null, null, null, false, true, false, table.getColumn(1)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(2)); Index index = table.getIndex(0); assertEquals(null, true, 2, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals(table.getColumn(0), null, index.getColumn(1)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"when\" primaryKey=\"false\" required=\"true\" type=\"TIMESTAMP\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <unique>\n" + " <unique-column name=\"when\" />\n" + " <unique-column name=\"id\" />\n" + " </unique>\n" + " </table>\n" + "</database>\n", model); }
Example 18
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an index. */ public void testSingleIndex() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <index>\n" + " <index-column name='value'/>\n" + " </index>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 2, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(1)); Index index = table.getIndex(0); assertEquals(null, false, 1, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <index>\n" + " <index-column name=\"value\" />\n" + " </index>\n" + " </table>\n" + "</database>\n", model); }
Example 19
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with an unique index. */ public void testSingleUniqueIndex() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndex'>\n" + " <column name='id'\n" + " type='DOUBLE'\n" + " primaryKey='true'\n" + " required='true'/>\n" + " <column name='value'\n" + " type='SMALLINT'\n" + " default='1'/>\n" + " <unique>\n" + " <unique-column name='value'/>\n" + " </unique>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndex", null, 2, 1, 0, 0, 1, table); assertEquals("id", Types.DOUBLE, 0, 0, null, null, null, true, true, false, table.getColumn(0)); assertEquals("value", Types.SMALLINT, 0, 0, "1", null, null, false, false, false, table.getColumn(1)); Index index = table.getIndex(0); assertEquals(null, true, 1, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndex\">\n" + " <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"DOUBLE\" autoIncrement=\"false\" />\n" + " <column name=\"value\" primaryKey=\"false\" required=\"false\" type=\"SMALLINT\" default=\"1\" autoIncrement=\"false\" />\n" + " <unique>\n" + " <unique-column name=\"value\" />\n" + " </unique>\n" + " </table>\n" + "</database>\n", model); }
Example 20
Source File: TestDatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Tests a database model with indices, both uniques and non-uniques. */ public void testMixedIndexes() throws Exception { Database model = readModel( "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" + " <table name='TableWithIndexes'>\n" + " <column name='id'\n" + " type='SMALLINT'\n" + " primaryKey='false'\n" + " required='true'\n" + " autoIncrement='true'/>\n" + " <column name='when'\n" + " type='DATE'/>\n" + " <unique name='important column'>\n" + " <unique-column name='id'/>\n" + " </unique>\n" + " <index>\n" + " <index-column name='when'/>\n" + " </index>\n" + " </table>\n" + "</database>"); assertEquals("test", model.getName()); assertEquals(1, model.getTableCount()); Table table = model.getTable(0); assertEquals("TableWithIndexes", null, 2, 0, 1, 0, 2, table); assertEquals("id", Types.SMALLINT, 0, 0, null, null, null, false, true, true, table.getColumn(0)); assertEquals("when", Types.DATE, 0, 0, null, null, null, false, false, false, table.getColumn(1)); assertEquals(table.getColumn(0), table.getAutoIncrementColumns()[0]); Index index = table.getIndex(0); assertEquals("important column", true, 1, index); assertEquals(table.getColumn(0), null, index.getColumn(0)); index = table.getIndex(1); assertEquals(null, false, 1, index); assertEquals(table.getColumn(1), null, index.getColumn(0)); assertEquals( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\"" + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n" + " <table name=\"TableWithIndexes\">\n" + " <column name=\"id\" primaryKey=\"false\" required=\"true\" type=\"SMALLINT\" autoIncrement=\"true\" />\n" + " <column name=\"when\" primaryKey=\"false\" required=\"false\" type=\"DATE\" autoIncrement=\"false\" />\n" + " <unique name=\"important column\">\n" + " <unique-column name=\"id\" />\n" + " </unique>\n" + " <index>\n" + " <index-column name=\"when\" />\n" + " </index>\n" + " </table>\n" + "</database>\n", model); }