/** * Add an index definition to this table. */ public void addIndex(IndexDefinition index) { getIndexes().add(index); }
/** * Add an index definition to this table. */ public void addIndex(IndexDefinition index) { getIndexes().add(index); }
public List<IndexDefinition> getTableIndexes() { return getTable().getIndexes(); }
public List<IndexDefinition> getTableIndexes() { return getTable().getIndexes(); }
@Override public void customize(Session session) throws SQLException { for (ClassDescriptor descriptor : session.getDescriptors().values()) { // Only change the table name for non-embedable entities with no // @Table already if (!descriptor.getTables().isEmpty() && descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) { String tableName = addUnderscores(descriptor.getTableName()); descriptor.setTableName(tableName); for (IndexDefinition index : descriptor.getTables().get(0).getIndexes()) { index.setTargetTable(tableName); } } for (DatabaseMapping mapping : descriptor.getMappings()) { // Only change the column name for non-embedable entities with // no @Column already if (mapping.getField() != null && !mapping.getAttributeName().isEmpty() && mapping.getField().getName().equalsIgnoreCase(mapping.getAttributeName())) { mapping.getField().setName(addUnderscores(mapping.getAttributeName())); } } } }
/** * Build a table definition object from a database table object */ protected TableDefinition getTableDefFromDBTable(DatabaseTable databaseTable) { TableDefinition tableDefinition = this.tableMap.get(databaseTable.getName()); if (tableDefinition == null) { //table not built yet, simply built it tableDefinition = new TableDefinition(); tableDefinition.setTable(databaseTable); tableDefinition.setName(databaseTable.getNameDelimited(databasePlatform)); tableDefinition.setQualifier(databaseTable.getTableQualifier()); if (databaseTable.hasUniqueConstraints()) { addUniqueKeyConstraints(tableDefinition, databaseTable.getUniqueConstraints()); } if (databaseTable.hasIndexes()) { tableDefinition.getIndexes().addAll(databaseTable.getIndexes()); } if (databaseTable.getCreationSuffix() !=null){ tableDefinition.setCreationSuffix(databaseTable.getCreationSuffix()); } // Add the foreign key constraints that were set on the table. if (databaseTable.hasForeignKeyConstraints()) { tableDefinition.setUserDefinedForeignKeyConstraints(databaseTable.getForeignKeyConstraints()); } tableMap.put(databaseTable.getName(), tableDefinition); } return tableDefinition; }
/** * Build a table definition object from a database table object */ protected TableDefinition getTableDefFromDBTable(DatabaseTable databaseTable) { TableDefinition tableDefinition = this.tableMap.get(databaseTable.getName()); if (tableDefinition == null) { //table not built yet, simply built it tableDefinition = new TableDefinition(); tableDefinition.setTable(databaseTable); tableDefinition.setName(databaseTable.getNameDelimited(databasePlatform)); tableDefinition.setQualifier(databaseTable.getTableQualifier()); if (databaseTable.hasUniqueConstraints()) { addUniqueKeyConstraints(tableDefinition, databaseTable.getUniqueConstraints()); } if (databaseTable.hasIndexes()) { tableDefinition.getIndexes().addAll(databaseTable.getIndexes()); } if (databaseTable.getCreationSuffix() !=null){ tableDefinition.setCreationSuffix(databaseTable.getCreationSuffix()); } // Add the foreign key constraints that were set on the table. if (databaseTable.hasForeignKeyConstraints()) { tableDefinition.setUserDefinedForeignKeyConstraints(databaseTable.getForeignKeyConstraints()); } tableMap.put(databaseTable.getName(), tableDefinition); } return tableDefinition; }