Package org.apache.ws.jaxme.sqls

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


      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


  }
 
  protected Table getMainTable() {
    if (mainTable == null) {
      Table mt = getSchema().newTable("MAIN");
      Column mtId = mt.newColumn("ID", Column.Type.BIGINT);
      Column mtVer = mt.newColumn("VER", Column.Type.INTEGER);
      StringColumn mtName = (StringColumn) mt.newColumn("NAME", Column.Type.VARCHAR);
      mtName.setLength(60);
      BinaryColumn mtSig = (BinaryColumn) mt.newColumn("SIG", Column.Type.BINARY);
      mtSig.setLength(16);
      mt.newColumn("DATE", Column.Type.DATE);
View Full Code Here

    if (subTable == null) {
      Table st = getSchema().newTable("SUB");
      StringColumn stId = (StringColumn) st.newColumn("ID", Column.Type.VARCHAR);
      stId.setLength(32);
     
      Column stMtId = st.newColumn("MTID", Column.Type.BIGINT);
      Column stMtVer = st.newColumn("MTVER", Column.Type.INTEGER);
      StringColumn stAddress = (StringColumn) st.newColumn("ADDRESS", Column.Type.VARCHAR);
      stAddress.setLength(60);
      StringColumn stEmail = (StringColumn) st.newColumn("EMAIL", Column.Type.VARCHAR);
      stEmail.setLength(60);
      stEmail.setNullable(true);
View Full Code Here

    if (subsubTable == null) {
      Table sst = getSchema().newTable("SUBSUB");
      StringColumn sstId = (StringColumn) sst.newColumn("ID", Column.Type.VARCHAR);
      sstId.setLength(32);
     
      Column sstMtId = sst.newColumn("MTID", Column.Type.BIGINT);
      Column sstMtVer = sst.newColumn("MTVER", Column.Type.INTEGER);
      ForeignKey foreignKeySt = sst.newForeignKey(getMainTable());
      foreignKeySt.addColumnLink(sstMtId, getMainTable().getColumn("ID"));
      foreignKeySt.addColumnLink(sstMtVer, getMainTable().getColumn("VER"));
     
      StringColumn sstStId = (StringColumn) sst.newColumn("SSTID", Column.Type.VARCHAR);
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

   
    /** <p>Creates a basic table</p>
     */
    protected Table getBasicTable() {
        Table table = schema.newTable("MyTable");
        Column myIndex = table.newColumn("MyIndex", Column.Type.INTEGER);
        assertTrue(!myIndex.isStringColumn());
        assertTrue(!myIndex.isBinaryColumn());
        Column myName = table.newColumn("MyName", Column.Type.VARCHAR);
        assertTrue(myName.isStringColumn()); // myName may be casted to a StringColumn
        assertTrue(!myName.isBinaryColumn());
        ((StringColumn) myName).setLength(60);
        Column myDate = table.newColumn("MyDate", Column.Type.DATE);
        assertTrue(!myDate.isStringColumn());
        assertTrue(!myDate.isBinaryColumn());
        myDate.setNullable(true);
        return table;
    }
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.