Ejemplo n.º 1
0
  private static Element createForeignKeyColumnElement(
      final Document dom, final ForeignKeyColumnReference fkcm) {
    final Element eForeignKey = dom.createElement("column");
    final Column referencingColumn = fkcm.getForeignKeyColumn();
    final Column referencedColumn = fkcm.getPrimaryKeyColumn();

    eForeignKey.setAttribute("name", referencingColumn.getName());
    eForeignKey.setAttribute("referencedtable", referencedColumn.getParent().getName());
    eForeignKey.setAttribute("referencedcolumn", referencedColumn.getName());

    return eForeignKey;
  }
Ejemplo n.º 2
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());
  }