Package org.apache.ws.jaxme.sqls

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


        return table;
    }
   
    protected Table getForeignKeyTable(Table pTable) {
        Table otherTable = pTable.getSchema().newTable("OtherTable");
        Column otherIndex = otherTable.newColumn("MyIndex", Column.Type.INTEGER);
        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"));
View Full Code Here


   
    /** <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 = getSQLGenerator();
        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

            default: throw new IllegalArgumentException("Column " + pColumnName +
                    " in table " + pTable.getQName() +
                    " has unknown JDBC data type " +
                    pDataType);
        }
        Column column = pTable.newColumn(pColumnName, type);
        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

      // in the map has a value > 1, then its column name must be
      // qualified, because it is used in multiple tables.
      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();
          addColumnName(col.getName());
        }
      }
    }
View Full Code Here

      }

      if (pType == null) {
         throw new NullPointerException("The column type must not be null.");
      }
      Column column = getColumn(pName);
      if (column != null) {
         throw new IllegalStateException("A column named " + column.getName() +
                                          " already exists in the table " + getQName());
      }
      column = ((SQLFactoryImpl) getSchema().getSQLFactory()).newColumnImpl(this, pName, pType);
      columns.add(column);
      return column;
View Full Code Here

   public Column getColumn(Column.Name pName) {
      if (pName == null) {
         throw new NullPointerException("Column names must not be null.");
      }
      for (Iterator iter = getColumns();  iter.hasNext()) {
         Column column = (Column) iter.next();
         if (getSchema().getSQLFactory().isColumnNameCaseSensitive()) {
            if (pName.getName().equalsIgnoreCase(column.getName().getName())) {
               return column;
            }
         } else {
            if (pName.equals(column.getName())) {
               return column;
            }
         }
      }
      return null;
View Full Code Here

   public SelectStatement getSelectStatement() {
      SelectStatement result = getSchema().getSQLFactory().newSelectStatement();
      result.setTable(this);
      TableReference ref = result.getTableReference();
      for (Iterator iter = getColumns();  iter.hasNext()) {
         Column column = (Column) iter.next();
         result.addResultColumn(new ColumnReferenceImpl(ref, column));
      }
      return result;
   }
View Full Code Here

    UpdateStatement result = getSchema().getSQLFactory().newUpdateStatement();
    result.setTable(this);
    TableReference ref = result.getTableReference();
    boolean hasPrimaryKey = false;
    for (Iterator iter = getColumns();  iter.hasNext()) {
      Column column = (Column) iter.next();
      if (column.isPrimaryKeyPart()) {
        hasPrimaryKey = true;
      } else {
        result.addSet(column);
      }
    }
View Full Code Here

  public ColumnReference newColumnReference(String pName) {
      return newColumnReference(new ColumnImpl.NameImpl(pName));
  }

  public ColumnReference newColumnReference(Column.Name pName) {
      Column column = getTable().getColumn(pName);
      if (column == null) {
         throw new NullPointerException("Unknown column name in table " + getTable().getName() +
                                         ": " + pName);
      }
      return newColumnReference(column);
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.