Package org.apache.ws.jaxme.sqls

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


  /** <p>Creates a table with a composed primary key.</p>
   */
  protected Table getComposedKeyTable() {
    Table table = getPrimaryKeyTable();
    Column verNumColumn = table.newColumn("VerNum", Column.Type.INTEGER);
    assertTrue(!verNumColumn.isStringColumn());
    assertTrue(!verNumColumn.isBinaryColumn());
    Index index = table.getPrimaryKey();
    index.addColumn("VerNum");
    return table;
  }
View Full Code Here


  public void testSubSelect() {
    SQLGenerator gen = sqlFactory.newSQLGenerator();
    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

     }
     return num.intValue() > 1;
   }

   protected String getColumnAlias(Map pColumnCounts, ColumnReference pColumn) {
     Column col = pColumn.getColumn();
     String s = col.getName().toString();
     if (col.isVirtual()) {
       VirtualColumn virtCol = (VirtualColumn) col;
       return virtCol.getValue() + " AS " + s;
     } else {
       if (isQualifiedColumn(pColumnCounts, pColumn)) {
         TableReference tableReference = pColumn.getTableReference();
View Full Code Here

      // qualified, because it is used in multiple tables.
      Map columnNames = new HashMap();
      for (int i = 0;  i < tables.size();  i++) {
        TableReference table = (TableReference) tables.get(i);
        for (Iterator iter = table.getTable().getColumns();  iter.hasNext()) {
          Column col = (Column) iter.next();
          String key = col.getName().toString().toUpperCase();
          Integer num = (Integer) columnNames.get(key);
          if (num == null) {
            num = new Integer(1);
          } else {
            num = new Integer(num.intValue() + 1);
View Full Code Here

  public boolean equals(Object o) {
    if (o == null  ||  !(o instanceof Column)) {
      return false;
    }
    Column other = (Column) o;
    Table table = getTable();
    if (table == null) {
      if (other.getTable() != null) {
        return false;
      }
    } else {
      if (!table.equals(other.getTable())) {
        return false;
      }
    }
    return getName().equals(other.getName());
  }
View Full Code Here

          throw new IllegalArgumentException("Invalid table name: " + tableName);
        }

        VersionGenerator.ColumnUpdater columnUpdater;
        if (isFirstTable) {
          Column column = null;
          int columnNum = -1;
          int i = 0;
          for (Iterator colIter = table.getColumns();  colIter.hasNext();  i++) {
            Column colIterColumn = (Column) colIter.next();
            if (colIterColumn.getName().equals(columnName)) {
              column = colIterColumn;
              columnNum = i;
              break;
            }
          }
          if (column == null) {
            throw new IllegalArgumentException("No column " + columnName +
                                               " found in table " + table.getQName());
          }
          isFirstTable = false;
          columnUpdater = new VerNumIncrementer(columnNum);
        } else {
          List pkColumns = new ArrayList();
          Index primaryKey = table.getPrimaryKey();
          if (primaryKey != null) {
            for (Iterator pkIter = primaryKey.getColumns();  pkIter.hasNext()) {
              Column pkColumn = (Column) pkIter.next();
              int columnNum = -1;
              int i = 0;
              for (Iterator colIter = table.getColumns();  colIter.hasNext();  i++) {
                Column colIterColumn = (Column) colIter.next();
                if (colIterColumn.getName().equals(pkColumn.getName())) {
                  columnNum = i;
                  break;
                }
              }
              if (columnNum == -1) {
View Full Code Here

      default: throw new IllegalArgumentException("Column " + pColumnName +
                                                    " in table " + pTable.getQName() +
                                                    " has unknown JDBC data type " +
                                                    pDataType);
    }
    Column column = pTable.newColumn(pColumnName, type);
    logger.finest(mName, "Found column " + pColumnName);
    if (column instanceof StringColumn) {
      ((StringColumn) column).setLength(pColumnSize);
    } else if (column instanceof BinaryColumn) {
      ((BinaryColumn) column).setLength(pColumnSize);
    }
    if (pNullable == DatabaseMetaData.columnNullable) {
      column.setNullable(true);
    }
    return column;
  }
View Full Code Here

  }

  protected Table getMainTable() {
     if (mainTable == null) {
        Table mt = getSchema().newTable("MAIN");
        Column mtId = mt.newColumn("ID", Column.Type.BIGINT);
        Column mtVer = mt.newColumn("VER", Column.Type.INTEGER);
        StringColumn mtName = (StringColumn) mt.newColumn("NAME", Column.Type.VARCHAR);
        mtName.setLength(60);
        BinaryColumn mtSig = (BinaryColumn) mt.newColumn("SIG", Column.Type.BINARY);
        mtSig.setLength(16);
        mt.newColumn("DATE", Column.Type.DATE);
View Full Code Here

    if (subTable == null) {
      Table st = getSchema().newTable("SUB");
      StringColumn stId = (StringColumn) st.newColumn("ID", Column.Type.VARCHAR);
      stId.setLength(32);

      Column stMtId = st.newColumn("MTID", Column.Type.BIGINT);
      Column stMtVer = st.newColumn("MTVER", Column.Type.INTEGER);
      StringColumn stAddress = (StringColumn) st.newColumn("ADDRESS", Column.Type.VARCHAR);
      stAddress.setLength(60);
      StringColumn stEmail = (StringColumn) st.newColumn("EMAIL", Column.Type.VARCHAR);
      stEmail.setLength(60);
      stEmail.setNullable(true);
View Full Code Here

     if (subsubTable == null) {
        Table sst = getSchema().newTable("SUBSUB");
        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);
View Full Code Here

TOP

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

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.