Package org.apache.ws.jaxme.sqls

Examples of org.apache.ws.jaxme.sqls.ForeignKey


        for (Iterator iter = pTable.getIndexes();  iter.hasNext()) {
            Index index = (Index) iter.next();
            result.addAll(getDrop(index));
        }
        for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
            ForeignKey key = (ForeignKey) iter.next();
            result.addAll(getDrop(key));
        }
        result.addAll(getDrop(pTable));
        return result;
    }
View Full Code Here


        Column referenceColumn = otherTable.newColumn("RefIndex", Column.Type.INTEGER);
        Column companyColumn = otherTable.newColumn("Company", Column.Type.VARCHAR);
        ((StringColumn) companyColumn).setLength(60);
        otherTable.newPrimaryKey().addColumn(otherIndex);
       
        ForeignKey reference = otherTable.newForeignKey(pTable);
        reference.addColumnLink(referenceColumn, pTable.getColumn("MyIndex"));
        return otherTable;
    }
View Full Code Here

        Table table = getComposedKeyTable();
       
        Table otherTable = table.getSchema().newTable("OtherTable");
        Column otherIndex = otherTable.newColumn("MyIndex", Column.Type.INTEGER);
        otherTable.newPrimaryKey().addColumn(otherIndex);
        ForeignKey foreignKey = otherTable.newForeignKey(table);
        SelectStatement selectStatement = sqlFactory.newSelectStatement();
        selectStatement.setTable(otherTable);
        DeleteStatement deleteStatement = sqlFactory.newDeleteStatement();
        deleteStatement.setTable(table);
        List columns = new ArrayList();
        for (Iterator iter = table.getColumns();  iter.hasNext()) {
            Column column = (Column) iter.next();
            Column refColumn = otherTable.newColumn("Ref" + column.getName(), column.getType());
            foreignKey.addColumnLink(refColumn, column);
            if (column.isPrimaryKeyPart()) {
                selectStatement.addResultColumn(selectStatement.getTableReference().newColumnReference(refColumn));
                columns.add(deleteStatement.getTableReference().newColumnReference(column));
            }
        }
View Full Code Here

      stEmail.setNullable(true);
     
      Index primaryKey = st.newPrimaryKey();
      primaryKey.addColumn(stId);
     
      ForeignKey foreignKey = st.newForeignKey(getMainTable());
      foreignKey.addColumnLink(stMtId, getMainTable().getColumn("ID"));
      foreignKey.addColumnLink(stMtVer, getMainTable().getColumn("VER"));
     
      subTable = st;
    }
    return subTable;
  }
View Full Code Here

      StringColumn sstId = (StringColumn) sst.newColumn("ID", Column.Type.VARCHAR);
      sstId.setLength(32);
     
      Column sstMtId = sst.newColumn("MTID", Column.Type.BIGINT);
      Column sstMtVer = sst.newColumn("MTVER", Column.Type.INTEGER);
      ForeignKey foreignKeySt = sst.newForeignKey(getMainTable());
      foreignKeySt.addColumnLink(sstMtId, getMainTable().getColumn("ID"));
      foreignKeySt.addColumnLink(sstMtVer, getMainTable().getColumn("VER"));
     
      StringColumn sstStId = (StringColumn) sst.newColumn("SSTID", Column.Type.VARCHAR);
      sstStId.setLength(32);
      ForeignKey foreignKeySst = sst.newForeignKey(getSubTable());
      foreignKeySst.addColumnLink(sstStId, getSubTable().getColumn("ID"));
     
      sst.newColumn("MTTS", Column.Type.TIMESTAMP);
    }
    return subsubTable;
  }
View Full Code Here

    logger.finest(mName, "Looking for foreign keys of " + pTable + "=" + pTable.getTable().getQName());
    List result = new ArrayList();
    ResultSet rs = pData.getImportedKeys(pTable.getCatalogName(),
                                         pTable.getSchemaName(),
                                         pTable.getTableName());
    ForeignKey foreignKey = null;
    boolean isRsClosed = false;
    try {
      while (rs.next()) {
        JDBCTable referencedTable = new JDBCTable(rs.getString(1), rs.getString(2),
                                                  rs.getString(3), "TABLE");
        String referencedColumnName = rs.getString(4);
        String localColumnName = rs.getString(8);
        logger.finest(mName, "Found column " + localColumnName + " referencing " +
                      referencedColumnName + " in " + referencedTable);
        for (int i = 0;  i < pTables.length;  i++) {
          JDBCTable refIterTable = pTables[i];
          if (refIterTable.equals(referencedTable)) {
            referencedTable.setTable(refIterTable.getTable());
            break;
          }
        }
        if (referencedTable.getTable() == null) {
          logger.finest(mName, "Unknown table, ignoring");
          continue;
        }

        short seq = rs.getShort(9);
        if (seq == 1) {
          foreignKey = pTable.getTable().newForeignKey(referencedTable.getTable());
          result.add(foreignKey);
        }
        foreignKey.addColumnLink(localColumnName, referencedColumnName);
      }

      isRsClosed = true;
      rs.close();
    } finally {
View Full Code Here

                sb.append(s).append(st);
            }
        }
        if (isForeignKeyPartOfCreateTable()) {
            for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
                ForeignKey key = (ForeignKey) iter.next();
                String st = createForeignKeyAsPartOfCreateTable(key);
                if (st != null) {
                    sb.append(s).append(st);
                }
            }
View Full Code Here

            }
            result.addAll(getCreate(index));
        }
        if (!isForeignKeyPartOfCreateTable()) {
            for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
                ForeignKey key = (ForeignKey) iter.next();
                result.addAll(getCreate(key));
            }
        }
        return result;
    }
View Full Code Here

        for (Iterator iter = pTable.getIndexes();  iter.hasNext()) {
            Index index = (Index) iter.next();
            result.addAll(getDrop(index));
        }
        for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
            ForeignKey key = (ForeignKey) iter.next();
            result.addAll(getDrop(key));
        }
        result.addAll(getDrop(pTable));
        return result;
    }
View Full Code Here

  private Set propertyNames = new HashSet();
  private boolean generatingLogging;
 
  private boolean isReferencing(Table pReferencingTable, Table pReferencedTable) {
    for (Iterator iter = pReferencingTable.getForeignKeys();  iter.hasNext()) {
      ForeignKey foreignKey = (ForeignKey) iter.next();
      if (foreignKey.getReferencedTable().equals(pReferencedTable)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.ForeignKey

Copyright © 2018 www.massapicom. 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.