Package org.apache.ws.jaxme.sqls

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


          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


  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

      if (table.getPrimaryKey() == null) {
        throw new IllegalStateException("The table " + table.getQName() + " does not have a primary key.");
      }
      CustomTableData customTableData = new CustomTableData(this, table, pTypeSG, pTableDetails);
      for (Iterator iter = table.getColumns();  iter.hasNext()) {
        Column col = (Column) iter.next();
        Object sg = addColumn(pTypeSG, pType, col);
        CustomColumnData colData = new CustomColumnData(col.getName().getName(), sg);
        col.setCustomData(colData);
      }

      return customTableData;
    } finally {
      if (conn != null) { try { conn.close(); } catch (Throwable ignore) {} }
View Full Code Here

  public void addColumnLink(Column pColumn, Column pReferencedColumn) {
    addColumnReference(new ColumnReferenceImpl(pColumn, pReferencedColumn));
  }

  public void addColumnReference(ForeignKey.ColumnLink pReference) {
    Column localColumn = pReference.getLocalColumn();
    if (!getTable().equals(localColumn.getTable())) {
      throw new IllegalStateException("The local column " + localColumn.getQName() +
                                       " is not from the local table " + getTable().getQName());
    }
    Column referencedColumn = pReference.getReferencedColumn();
    if (!getReferencedTable().equals(referencedColumn.getTable())) {
      throw new IllegalStateException("The referenced column " + referencedColumn.getQName() +
                                       " is not from the referenced table " + getReferencedTable().getQName());
    }
    references.add(pReference);
  }
View Full Code Here

    }
    references.add(pReference);
  }

  public void addColumnLink(Column.Name pName, Column.Name pReferencedName) {
      Column localColumn = getTable().getColumn(pName);
      if (localColumn == null) {
        throw new NullPointerException("The local table " + getTable().getQName() +
                                        " doesn't contain a column " + pName);
      }
      Column referencedColumn = getReferencedTable().getColumn(pReferencedName);
      if (referencedColumn == null) {
         throw new NullPointerException("The referenced table " + getReferencedTable().getName() +
                                         " doesn't contain a column " + pReferencedName);
      }
      addColumnLink(localColumn, referencedColumn);
View Full Code Here

    Index index = getTable().getPrimaryKey();
    if (index == null) {
      return false;
    }
    for (Iterator iter = index.getColumns();  iter.hasNext()) {
      Column column = (Column) iter.next();
      if (column.equals(this)) {
        return true;
      }
    }
    return false;
  }
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.