Search in sources :

Example 6 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Constraints

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Constraints in project jaxdb by jaxdb.

the class Compiler method blockPrimaryKey.

String blockPrimaryKey(final $Table table, final $Constraints constraints, final Map<String, ColumnRef> columnNameToColumn) throws GeneratorExecutionException {
    if (constraints.getPrimaryKey() == null)
        return "";
    final StringBuilder builder = new StringBuilder();
    final List<$Named> columns = constraints.getPrimaryKey().getColumn();
    final PrimaryKey.Using$ using = constraints.getPrimaryKey().getUsing$();
    final int[] columnIndexes = new int[columns.size()];
    final Iterator<$Named> iterator = columns.iterator();
    for (int i = 0; iterator.hasNext(); ++i) {
        final $Named primaryColumn = iterator.next();
        final String primaryKeyColumn = primaryColumn.getName$().text();
        final ColumnRef ref = columnNameToColumn.get(primaryKeyColumn);
        if (ref == null)
            throw new GeneratorExecutionException("PRIMARY KEY column " + table.getName$().text() + "." + primaryKeyColumn + " is not defined");
        if (ref.column.getNull$() == null || ref.column.getNull$().text())
            throw new GeneratorExecutionException("Column " + ref.column.getName$() + " must be NOT NULL to be a PRIMARY KEY");
        if (i > 0)
            builder.append(", ");
        builder.append(q(primaryKeyColumn));
        columnIndexes[i] = ref.index;
    }
    return ",\n  " + primaryKey(table, columnIndexes, using) + " (" + builder + ")";
}
Also used : org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named) PrimaryKey(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Constraints.PrimaryKey) ColumnRef(org.jaxdb.ddlx.Generator.ColumnRef) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)

Aggregations

org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)5 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)5 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$CheckReference (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$CheckReference)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int)3 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer)3 GeneratorExecutionException (org.jaxdb.ddlx.GeneratorExecutionException)2 org.jaxdb.jsql.data (org.jaxdb.jsql.data)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime)2 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum)2