Package org.apache.ws.jaxme.sqls

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


    protected String getFunction(StatementMetaData pData, Function f) {
        return f.getName() + '(' + getParts(pData, f.getParts()) + ')';
    }
   
    protected String getColumnAlias(StatementMetaData 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

  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

      // 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

      }
      columns.add(pColumn);
  }

   public void addColumn(Column.Name pName) {
      Column column = getTable().getColumn(pName);
      if (column == null) {
         throw new NullPointerException("The table " + getTable().getName() + " doesn't contain a column " + pName);
      }
      addColumn(column);
   }
View Full Code Here

    pMethod.addTry();
   
    int paramNum = 0;
    for (Iterator iter = pColumnSet.getColumns();  iter.hasNext()) {
      Object v = new Object[]{pValues, "[", Integer.toString(paramNum), "]"};
      Column column = (Column) iter.next();
      setPreparedStatementValue(pMethod, column, stmt, Integer.toString(++paramNum), v);
    }
    LocalJavaField rs = pMethod.newJavaField(ResultSet.class, "rs");
    rs.addLine(stmt, ".executeQuery()");
    LocalJavaField isRsClosed = pMethod.newJavaField(boolean.class);
    isRsClosed.addLine("false");
    LocalJavaField result;
    if (pReturnValue) {
      result = pMethod.newJavaField(Object[].class, "result");
      result.addLine("null");
    } else {
      result = null;
    }
    pMethod.addTry();
   
    pMethod.addWhile(rs, ".next()");
    if (result != null) {
      pMethod.addIf(result, " != null");
      pMethod.addThrowNew(IllegalStateException.class,
          JavaSource.getQuoted("Expected a single row only."));
      pMethod.addEndIf();
    }
   
    int resultColumnSize = 0;
    for (Iterator iter = table.getColumns();  iter.hasNext();  iter.next()) {
      ++resultColumnSize;
    }
    LocalJavaField row = pMethod.newJavaField(Object[].class, "row");
    row.addLine("new ", Object.class, "[" + resultColumnSize + "];");
   
    int resultColumnNum = 0;
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column column = (Column) iter.next();
      setResultSetValue(pMethod, column, rs, resultColumnNum++, row);
    }
   
    pMethod.addLine(((result == null) ? "" : "result = "),
        getInsertRowMethodName(pTableInfo), "(", pConn, ", ", pMap, ", ",
View Full Code Here

                             ColumnSet pColumnSet,
                             DirectAccessible pValues) {
    Table table = pColumnSet.getTable();
    List params = new ArrayList();
    for (Iterator iter = pColumnSet.getColumns();  iter.hasNext()) {
      Column primaryKeyColumn = (Column) iter.next();
      int index = -1;
      int i = 0;
      for (Iterator iter2 = table.getColumns();  iter2.hasNext();  ++i) {
        Column tableColumn = (Column) iter2.next();
        if (tableColumn.equals(primaryKeyColumn)) {
          index = i;
          break;
        }
      }
      if (index == -1) {
View Full Code Here

                   ColumnSet pColumnSet,
                   DirectAccessible pRow,
                   DirectAccessible pData) {
    Table table = pTableInfo.getTable();
    for (Iterator iter = pColumnSet.getColumns();  iter.hasNext()) {
      Column primaryKeyColumn = (Column) iter.next();
      int index = -1;
      int i = 0;
      for (Iterator iter2 = table.getColumns();  iter2.hasNext();  ++i) {
        Column tableColumn = (Column) iter2.next();
        if (tableColumn.equals(primaryKeyColumn)) {
          index = i;
          break;
        }
      }
      if (index == -1) {
View Full Code Here

    isStmtClosed.addLine("false");
    jm.addTry();
   
    int paramNum = 0;
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column column = (Column) iter.next();
      Object v = new Object[]{ values, "[", Integer.toString(paramNum), "]" };
      setPreparedStatementValue(jm, column, stmt, Integer.toString(++paramNum), v);
    }
   
    jm.addLine(stmt, ".executeUpdate();");
View Full Code Here

    jc.addLine("The key values are given by the array <code>pRow</code>:");
    jc.addLine("<ul>");
    int i = 0;
    for (Iterator iter = headTable.getTable().getPrimaryKey().getColumns();
        iter.hasNext();  i++) {
      Column col = (Column) iter.next();
      jc.addLine("  <li><code>pRow[" + i+ "] = " + col.getQName() + "</code></li>");
    }
    jc.addLine("</ul>");
    jc.addLine("The method updates the rows version number and creates a new row");
    jc.addLine("with the updated values.</p>");
    {
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.