Package org.apache.ws.jaxme.sqls

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


    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

                          JavaSource.getQuoted("Unknown reference: "), " + ",
                          referencedKey);
      pMethod.addEndIf();
      int valNum = 0;
      for (Iterator iter = referencedTable.getTable().getPrimaryKey().getColumns();  iter.hasNext()) {
        Column referencedKeyColumn = (Column) iter.next();
        Column localColumn = null;
        for (Iterator iter2 = foreignKey.getColumnLinks();  iter2.hasNext()) {
          ForeignKey.ColumnLink link = (ForeignKey.ColumnLink) iter2.next();
          if (link.getReferencedColumn().equals(referencedKeyColumn)) {
            localColumn = link.getLocalColumn();
            break;
          }
        }
        if (localColumn == null) {
          throw new IllegalStateException("Unable to find the column referencing " + referencedKeyColumn.getQName());
        }

        int colNum = -1, i = 0;
        for (Iterator iter2 = pTableInfo.getTable().getColumns();  iter2.hasNext()) {
           Column col = (Column) iter2.next();
           if (col.equals(localColumn)) {
              colNum = i;
              break;
           }
           ++i;
        }
View Full Code Here

  private int getPreparedStatementParameters(JavaMethod pMethod, Object pStmt, DirectAccessible pElement,
                                             Iterator pColumns, int pParamNum)
      throws SAXException {
    for (Iterator iter = pColumns;  iter.hasNext()) {
      Column col = (Column) iter.next();
      CustomColumnData colData = (CustomColumnData) col.getCustomData();
      Object sg = colData.getSG();
      PropertySG propertySG;
      TypeSG typeSG;
      if (sg instanceof AttributeSG) {
        AttributeSG attrSG = (AttributeSG) sg;
        propertySG = attrSG.getPropertySG();
        typeSG = attrSG.getTypeSG();
      } else if (sg instanceof ParticleSG) {
        ParticleSG particleSG = (ParticleSG) sg;
        propertySG = particleSG.getPropertySG();
        typeSG = particleSG.getObjectSG().getTypeSG();
      } else {
        throw new IllegalStateException("Invalid SG type for column " + col.getName() + ": " + sg);
      }
      Object value = propertySG.getValue(pElement);
      setPreparedStatementValue(pMethod, col, pStmt, new Integer(++pParamNum), value, typeSG);
    }
    return pParamNum;
View Full Code Here

  private int getResultSet(JavaMethod pMethod, DirectAccessible pRs, DirectAccessible pElement,
                            Iterator pColumns, int pParamNum)
      throws SAXException {
    for (Iterator iter = pColumns;  iter.hasNext()) {
      Column col = (Column) iter.next();
      CustomColumnData colData = (CustomColumnData) col.getCustomData();
      Object sg = colData.getSG();
      PropertySG propertySG;
      TypeSG typeSG;
      if (sg instanceof AttributeSG) {
        AttributeSG attrSG = (AttributeSG) sg;
        propertySG = attrSG.getPropertySG();
        typeSG = attrSG.getTypeSG();
      } else if (sg instanceof ParticleSG) {
        ParticleSG particleSG = (ParticleSG) sg;
        propertySG = particleSG.getPropertySG();
        typeSG = particleSG.getObjectSG().getTypeSG();
      } else {
        throw new IllegalStateException("Invalid SG type for column " + col.getName() + ": " + sg);
      }
      Object value = getResultSetValue(pMethod, col, pRs, new Integer(++pParamNum), typeSG);
      propertySG.setValue(pMethod, pElement, value, null);
    }
    return pParamNum;
View Full Code Here

    stmt.addLine(connection, ".prepareStatement(", query, ")");
    jm.addTry();

    List nonKeyColumns = new ArrayList();
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column col = (Column) iter.next();
      if (!col.isPrimaryKeyPart()) {
        nonKeyColumns.add(col);
      }
    }
    int i = 0;
    i = getPreparedStatementParameters(jm, stmt, elem, nonKeyColumns.iterator(), i);
View Full Code Here

    Table table = pData.getTable();

    JavaQName qName = pController.getComplexTypeSG().getClassContext().getXMLInterfaceName();
    StringBuffer sb = new StringBuffer();
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column col = (Column) iter.next();
      if (sb.length() > 0) sb.append(", ");
      sb.append(col.getName().getName());
    }
    LocalJavaField query = jm.newJavaField(String.class);
    jm.addIf(pParams, " != null  &&  pParams.isDistinct()");
    jm.addLine(query, " = ", JavaSource.getQuoted("SELECT DISTINCT"), ";");
    jm.addElse();
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.