Examples of DBForeignKeyConstraint


Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

      out.println("    <td>" + column.getName() + "</td>");
      out.println("    <td>" + SQLUtil.renderColumnTypeWithSize(column) + "</td>");
      out.println("    <td>" + (column.isNullable() ? "" : "NOT NULL") + "</td>");
      out.println("    <td>" + (column.getDefaultValue() != null ? column.getDefaultValue() : "") + "</td>");
      out.println("    <td>" + (pk != null && ArrayUtil.contains(column.getName(), pk.getColumnNames()) ? "PK" : "") + "</td>");
      DBForeignKeyConstraint fk = column.getForeignKeyConstraint();
      out.println("    <td>" + (fk != null ? "FK --> " + linkFor(fk.getRefereeTable(), tableFile(table, context)) : "") + "</td>");
      out.println("  </tr>");
    }
    out.println("  </table>");
    HtmlReportUtil.endModule(out);
  }
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

      TableChange tableChange) {
    for (DBForeignKeyConstraint fk1 : fks1) {
      // search an analogous uk in the second table
      String tableName1 = fk1.getTable().getName();
      String[] colNames1 = fk1.getColumnNames();
      DBForeignKeyConstraint fk2 = null;
      for (DBForeignKeyConstraint tmp : fks2) {
        if (!tmp.getTable().getName().equals(tableName1))
          continue;
        String[] colNames2 = tmp.getColumnNames();
        if (Arrays.equals(colNames2, colNames1)) {
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

public class TableCreationValuator implements SchemaChangeProcessor {
 
  public void process(SchemaChange schemaChange) {
    // check all new FKs...
    for (ForeignKeyConstraintCreation fkCreation : schemaChange.getSubChanges(ForeignKeyConstraintCreation.class)) {
      DBForeignKeyConstraint fk = fkCreation.getAffectedObject();
      String refereeTableName = fk.getRefereeTable().getName();
      TableCreation refereeTableCreation = schemaChange.getSubChange(TableCreation.class, refereeTableName);
      if (refereeTableCreation != null && DBUtil.containsMandatoryColumn(fk)) {
        // a new 'not null' fk on an old column referring a new table makes the table creation an AUGMENTATION...
        refereeTableCreation.setTypeAndSeverity("created table with mandatory reference from remaining table",
            ChangeSeverity.AUGMENTATION);
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

  public void testFKCreated() {
    // given a table to which a foreign key was added
    DBTable target = createTableWithColumns("target", 2);
    DBTable table1 = createTableWithColumns("tbl", 2);
    DBTable table2 = createTableWithColumns("tbl", 2);
    new DBForeignKeyConstraint("fk1", false, table2, new String[] { "col1" }, target, new String[] { "col1" });
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a foreign key creation
    System.out.println(schemaChange);
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

  @Test
  public void testFKDeleted() {
    // given a table from which a foreign key constraint was removed
    DBTable target = createTableWithColumns("target", 2);
    DBTable table1 = createTableWithColumns("tbl", 2);
    new DBForeignKeyConstraint("fk1", false, table1, new String[] { "col1" }, target, new String[] { "col1" });
    DBTable table2 = createTableWithColumns("tbl", 2);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a foreign key deletion
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

  @Test
  public void testFKOnDifferentColumn() {
    // given a table from which a foreign key constraint was removed
    DBTable target = createTableWithColumns("target", 2);
    DBTable table1 = createTableWithColumns("tbl", 2);
    new DBForeignKeyConstraint("fk1", false, table1, new String[] { "col1" }, target, new String[] { "col1" });
    DBTable table2 = createTableWithColumns("tbl", 2);
    new DBForeignKeyConstraint("fk1", false, table2, new String[] { "col2" }, target, new String[] { "col2" });
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a foreign key creation
    System.out.println(schemaChange);
View Full Code Here

Examples of org.databene.jdbacl.model.DBForeignKeyConstraint

    DBTable refererTable = new DBTable("referer");
    DBColumn fkColumn = new DBColumn("ref", refererTable, DBDataType.getInstance(Types.INTEGER, "int"));
    fkColumn.setNullable(nullableFk);
    refereeTable.addColumn(fkColumn);
    schemaChange.addSubChange(new TableCreation(refereeTable));
    DBForeignKeyConstraint fk = new DBForeignKeyConstraint("new_fk", true, refererTable, new String[] { "ref" }, refereeTable, new String[] { "id" });
    schemaChange.addSubChange(new ForeignKeyConstraintCreation(fk));
    return schemaChange;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.