Package org.apache.ws.jaxme.sqls

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


     * </pre>
     */
  private JoinReference getFirstRowStatement2(String pFilter, TableReference pAkteReference,
                            SelectTableReference pJoinReference,
                            String pTableAlias) {
      Column aName = dbBeteiligte.getColumn("aName");
        Column aVorname = dbBeteiligte.getColumn("aVorname");
        Column aAktenId = dbBeteiligte.getColumn("aAktenId");
        Column aFilter = dbBeteiligte.getColumn("aFilter");

        SelectStatement st = sqlFactory.newSelectStatement();
        st.setTable(dbBeteiligte);
        SelectTableReference ref = st.getSelectTableReference();
        VirtualColumn num = new VirtualColumn("NUM", Column.Type.INTEGER);
        num.setValue("COUNT(*) OVER (PARTITION BY " + aAktenId.getName() + ")");
        st.addResultColumn(num);
        VirtualColumn minAName = new VirtualColumn("MINANAME", Column.Type.VARCHAR);
        minAName.setValue("MIN(UPPER(" + aName.getName() + ")) OVER (PARTITION BY " +
                      aAktenId.getName() + ")");
        st.addResultColumn(minAName);
        VirtualColumn minAVorname = new VirtualColumn("MINAVORNAME", Column.Type.VARCHAR);
        minAVorname.setValue("MIN(UPPER(NVL(" + aVorname.getName() +
                       ", ' '))) OVER (PARTITION BY " +
                        aAktenId.getName() + ", UPPER(" + aName.getName() +
                        "))");
        st.addResultColumn(minAVorname);
        st.addResultColumn(ref.newColumnReference(aName));
        st.addResultColumn(ref.newColumnReference(aVorname));
        st.addResultColumn(ref.newColumnReference(aAktenId));
        BooleanConstraint bc = st.getWhere().createEQ();
        bc.addPart(st.getTableReference().newColumnReference(aFilter));
        bc.addPart(pFilter);
        Table t = st.createView((Table.Name) null);

        SelectStatement st2 = sqlFactory.newSelectStatement();
        st2.setTable(t);
        SelectTableReference ref2 = st2.getSelectTableReference();
        st2.addResultColumn(ref2.newColumnReference(t.getColumn("NUM")));
        Column aName2 = t.getColumn(aName.getName());
        st2.addResultColumn(ref2.newColumnReference(aName2));
        Column aVorname2 = t.getColumn(aVorname.getName());
        st2.addResultColumn(ref2.newColumnReference(aVorname2));
        st2.addResultColumn(ref2.newColumnReference(t.getColumn(aAktenId.getName())));

        bc = st2.getWhere().createEQ();
        bc.addPart(ref2.newColumnReference(t.getColumn("MINAVORNAME")));
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

        }
        if (!pTableReference.getStatement().equals(getConstrainedStatement())) {
            throw new IllegalStateException("The statement of the table reference is not the same as this constraints statement.");
        }
        for (Iterator iter = pSet.getColumns();  iter.hasNext()) {
            Column column = (Column) iter.next();
            BooleanConstraint eq = createEQ();
            eq.addPart(new ColumnReferenceImpl(pTableReference, column));
            eq.addPlaceholder();
        }
    }
View Full Code Here

                    pReferencedTable.getTable().getQName());
        }
       
        Iterator referencedIter = pReferencedColumnSet.getColumns();
        for (Iterator iter = pReferencingColumnSet.getColumns();  iter.hasNext()) {
            Column referencingColumn = (Column) iter.next();
            if (!referencedIter.hasNext()) {
                throw new IllegalStateException("The size of the referencing and referenced column sets doesn't match.");
            }
            Column referencedColumn = (Column) referencedIter.next();
            BooleanConstraint eq = createEQ();
            eq.addPart(pReferencingTable.newColumnReference(referencingColumn));
            eq.addPart(pReferencedTable.newColumnReference(referencedColumn));
        }
    }
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

    protected String getFunction(SelectStatementMetaData pData, Function f) {
        return f.getName() + '(' + getParts(pData, f.getParts()) + ')';
    }
   
    protected String getColumnAlias(SelectStatementMetaData pData, ColumnReference pColumn) {
        Column col = pColumn.getColumn();
        String s = col.getName().toString();
        if (col.isVirtual()) {
            VirtualColumn virtCol = (VirtualColumn) col;
            Object o = virtCol.getValue();
            if (o instanceof SelectStatement) {
                return "(" + getSelectQuery((SelectStatement) o, pData) + ") AS " + s;
            } else if (o instanceof Function) {
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

        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

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.