Search in sources :

Example 1 with ModelException

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(")");
}
Also used : ModelException(org.jumpmind.db.model.ModelException) Column(org.jumpmind.db.model.Column) IndexColumn(org.jumpmind.db.model.IndexColumn) PlatformColumn(org.jumpmind.db.model.PlatformColumn) IndexColumn(org.jumpmind.db.model.IndexColumn)

Aggregations

Column (org.jumpmind.db.model.Column)1 IndexColumn (org.jumpmind.db.model.IndexColumn)1 ModelException (org.jumpmind.db.model.ModelException)1 PlatformColumn (org.jumpmind.db.model.PlatformColumn)1