Package org.apache.ws.jaxme.sqls

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


    if (pUpdater != null) {
      tableInfo.add(pUpdater);
    }
   
    for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
      ForeignKey foreignKey = (ForeignKey) iter.next();
      Table referencedTable = foreignKey.getReferencedTable();
      for (Iterator iter2 = tablesByOrder.iterator();  iter2.hasNext()) {
        TableInfo referencedTableInfo = (TableInfo) iter2.next();
        if (referencedTableInfo.getTable().equals(referencedTable)) {
          ColumnUpdater columnUpdater = new ForeignKeyUpdater(foreignKey, referencedTableInfo);
          tableInfo.add(columnUpdater);
View Full Code Here


    LocalJavaField referencedValues = null;
    for (Iterator referencingIter = tablesByOrder.iterator();  referencingIter.hasNext()) {
      TableInfo prevTableInfo = (TableInfo) referencingIter.next();
      Table prevTable = prevTableInfo.getTable();
      for (Iterator fkIter = prevTable.getForeignKeys();  fkIter.hasNext()) {
        ForeignKey fk = (ForeignKey) fkIter.next();
        if (fk.getReferencedTable().equals(table)) {
          if (referencedValues == null) {
            referencedValues = jm.newJavaField(Object[].class);
            referencedValues.addLine(baseKey, ".getValues()");
          }
          getSelectRowsCode(jm, prevTableInfo, fk, connection, map, referencedValues, false);
View Full Code Here

   public Iterator getForeignKeys() {
      return foreignKeys.iterator();
   }

   public ForeignKey newForeignKey(Table pTable) {
      ForeignKey foreignKey = new ForeignKeyImpl(this, pTable);
      foreignKeys.add(foreignKey);
      return foreignKey;
   }
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

  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

    if (pUpdater != null) {
      tableInfo.add(pUpdater);
    }
   
    for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
      ForeignKey foreignKey = (ForeignKey) iter.next();
      Table referencedTable = foreignKey.getReferencedTable();
      for (Iterator iter2 = tablesByOrder.iterator();  iter2.hasNext()) {
        TableInfo referencedTableInfo = (TableInfo) iter2.next();
        if (referencedTableInfo.getTable().equals(referencedTable)) {
          ColumnUpdater columnUpdater = new ForeignKeyUpdater(foreignKey, referencedTableInfo);
          tableInfo.add(columnUpdater);
View Full Code Here

    LocalJavaField referencedValues = null;
    for (Iterator referencingIter = tablesByOrder.iterator();  referencingIter.hasNext()) {
      TableInfo prevTableInfo = (TableInfo) referencingIter.next();
      Table prevTable = prevTableInfo.getTable();
      for (Iterator fkIter = prevTable.getForeignKeys();  fkIter.hasNext()) {
        ForeignKey fk = (ForeignKey) fkIter.next();
        if (fk.getReferencedTable().equals(table)) {
          if (referencedValues == null) {
            referencedValues = jm.newJavaField(Object[].class);
            referencedValues.addLine(baseKey, ".getValues()");
          }
          getSelectRowsCode(jm, prevTableInfo, fk, connection, map, referencedValues, false);
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

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.