コード例 #1
0
  protected void writeCompoundUniqueConstraints(DdlBuffer apply, CreateTable createTable)
      throws IOException {

    String tableName = createTable.getName();

    List<UniqueConstraint> uniqueConstraints = createTable.getUniqueConstraint();
    for (UniqueConstraint uniqueConstraint : uniqueConstraints) {
      String[] columns = toColumnNamesSplit(uniqueConstraint.getColumnNames());
      apply
          .append(
              platformDdl.alterTableAddUniqueConstraint(
                  tableName, uniqueConstraint.getName(), columns))
          .endOfStatement();
    }
  }
コード例 #2
0
  protected void addUniqueConstraint(DdlWrite writer, AlterColumn alter, String uqName)
      throws IOException {

    String[] cols = {alter.getColumnName()};

    writer
        .apply()
        .append(platformDdl.alterTableAddUniqueConstraint(alter.getTableName(), uqName, cols))
        .endOfStatement();

    writer
        .rollbackForeignKeys()
        .append(platformDdl.dropIndex(uqName, alter.getTableName()))
        .endOfStatement();
  }
コード例 #3
0
  /**
   * Specific handling of OneToOne unique constraints for MsSqlServer. For all other DB platforms
   * these unique constraints are done inline as per normal.
   */
  protected void writeUniqueOneToOneConstraints(DdlWrite write, CreateTable createTable)
      throws IOException {

    String tableName = createTable.getName();
    for (Column col : externalUnique) {
      String uqName = col.getUniqueOneToOne();
      String[] columnNames = {col.getName()};
      write
          .apply()
          .append(platformDdl.alterTableAddUniqueConstraint(tableName, uqName, columnNames))
          .endOfStatement();

      write.rollbackForeignKeys().append(platformDdl.dropIndex(uqName, tableName)).endOfStatement();
    }
  }