Beispiel #1
0
  private static boolean isOutgoingForeignKey(final Table table, final ForeignKey foreignKey) {
    final List<ForeignKeyColumnReference> fkcms = foreignKey.getColumnReferences();
    ThreadContext.assertFault(
        fkcms.size() > 0,
        "Table [%s] reports a foreign key [%s] with no columns",
        table.getName(),
        foreignKey.getName());
    final ForeignKeyColumnReference fkcm = fkcms.get(0);

    final Column referencedColumn = fkcm.getPrimaryKeyColumn();
    final String referencedtableName = referencedColumn.getParent().getName();

    return !referencedtableName.equals(table.getName());
  }
Beispiel #2
0
  private static Element createForeignKeyElement(final Document dom, final ForeignKey foreignKey) {
    // <constraint name="C1" type="compoundforeignkey">
    //     <column name="ActivationDate" referencedtable="ActivationDate" referencedcolumn="Value"/>
    // </constraint>
    final Element eForeignKey = dom.createElement("constraint");
    eForeignKey.setAttribute("name", foreignKey.getName());
    eForeignKey.setAttribute("type", "compoundforeignkey");

    final List<ForeignKeyColumnReference> fkcms = foreignKey.getColumnReferences();
    for (final ForeignKeyColumnReference fkcm : fkcms) {
      final Element eColumn = createForeignKeyColumnElement(dom, fkcm);
      eForeignKey.appendChild(eColumn);
    }

    return eForeignKey;
  }