use of org.jumpmind.db.model.ModelException in project symmetric-ds by JumpMind.
the class AbstractDdlBuilder method writeEmbeddedIndexCreateStmt.
/**
* Writes the given embedded index of the table.
*/
protected void writeEmbeddedIndexCreateStmt(Table table, IIndex index, StringBuilder ddl) {
if ((index.getName() != null) && (index.getName().length() > 0)) {
ddl.append(" CONSTRAINT ");
printIdentifier(getIndexName(index), ddl);
}
if (index.isUnique()) {
ddl.append(" UNIQUE");
} else {
ddl.append(" INDEX ");
}
ddl.append(" (");
for (int idx = 0; idx < index.getColumnCount(); idx++) {
IndexColumn idxColumn = index.getColumn(idx);
Column col = table.findColumn(idxColumn.getName());
if (col == null) {
// exception
throw new ModelException("Invalid column '" + idxColumn.getName() + "' on index " + index.getName() + " for table " + table.getName());
}
if (idx > 0) {
ddl.append(", ");
}
printIdentifier(getColumnName(col), ddl);
}
ddl.append(")");
}
Aggregations