Package org.apache.ws.jaxme.sqls

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


        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate, null AS virtCol FROM MySchema.MyTable", query);
    }

    public void testNOT() {
        Table table = getBasicTable();
        SelectStatement selectStatement = table.getSelectStatement();
        SelectTableReference ref = selectStatement.getSelectTableReference();
        CombinedConstraint and = selectStatement.getWhere();
        BooleanConstraint bc = and.createLIKE();
        bc.addPart(ref.newColumnReference("MyName"));
        bc.addPart("%a%");
View Full Code Here


    }

    protected void addSelectStatement(SelectStatement pQuery) {
        for (Iterator tableIter = pQuery.getSelectTableReferences();  tableIter.hasNext()) {
            TableReference tableReference = (TableReference) tableIter.next();
            Table t = tableReference.getTable();
            Table.Name alias = tableReference.getAlias();
            if (alias != null) {
                if (aliases.containsKey(alias.getName())) {
                    throw new IllegalStateException("The alias " + alias +
                            " is used twice ");
View Full Code Here

   public boolean equals(Object o) {
      if (o == null  ||  !(o instanceof Table)) {
         return false;
      }
      Table other = (Table) o;
      if (!getSchema().equals(other.getSchema())) {
         return false;
      }
      return getName().equals(other.getName());
   }
View Full Code Here

    }
   
    protected boolean isTableAliasUsingAs() { return true; }
   
    protected String getTableAlias(SelectStatementMetaData pData, TableReference pTable) {
        Table t = pTable.getTable();
        String tableName;
        Table.Name alias = pTable.getAlias();
        if (t instanceof ViewImpl) {
            ViewImpl v = (ViewImpl) t;
            tableName = "(" + getSelectQuery(v.getViewStatement(), pData) + ")";
View Full Code Here

    public Collection getCreate(Schema pSchema, boolean pAll) {
        if (!pAll) { return getCreate(pSchema); }
        List result = new ArrayList();
        result.addAll(getCreate(pSchema));
        for (Iterator iter = pSchema.getTables();  iter.hasNext()) {
            Table table = (Table) iter.next();
            result.addAll(getCreate(table, true));
        }
        return result;
    }
View Full Code Here

        for (Iterator iter = pSchema.getTables();  iter.hasNext()) {
            tables.add(iter.next());
        }
        Collections.reverse(tables);
        for (Iterator iter = tables.iterator();  iter.hasNext()) {
            Table table = (Table) iter.next();
            result.addAll(getDrop(table, true));
        }
        result.addAll(getDrop(pSchema));
        return result;
    }
View Full Code Here

    final String mName = "readTable";
    ResultSet rs = pData.getColumns(pTable.getCatalogName(), pTable.getSchemaName(),
                                    pTable.getTableName(), null);
    boolean isRsClosed = false;
    try {
      Table sqlTable = pSchema.newTable(pTable.getTableName());
      logger.finest(mName, "Looking for columns of " + pTable + "=" + sqlTable.getQName());
      while (rs.next()) {
        String columnName = rs.getString(4);
        int dataType = rs.getInt(5);
        String typeName = rs.getString(6);
        long columnSize = rs.getLong(7);
View Full Code Here

    } else if (tables.length == 1) {
      jdbcTable = tables[0];
    } else {
      throw new IllegalStateException("Multiple tables named " + pTable + " found in schema " + pSchema);
    }
    Table result = readTable(metaData, schema, jdbcTable);
    readPrimaryKey(metaData, jdbcTable);
    return result;
  }
View Full Code Here

        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")));
        Function f = st2.createFunction("MIN");
        Function f2 = st.createFunction("UPPER");
        Function f3 = st.createFunction("NVL");
        f3.addPart(ref2.newColumnReference(aVorname2));
        f3.addPart(" ");
        f2.addPart(f3);
        bc.addPart(f);

        bc = st2.getWhere().createEQ();
        bc.addPart(ref2.newColumnReference(t.getColumn("MINANAME")));
        f = st2.createFunction("MIN");
        f2 = st.createFunction("UPPER");
        f2.addPart(ref2.newColumnReference(aName2));
        f.addPart(f2);
        bc.addPart(f);
        Table t2 = st2.createView(pTableAlias);

        JoinReference result = pJoinReference.leftOuterJoin(t2);
        bc = result.getOn().createEQ();
        bc.addPart(pAkteReference.newColumnReference(dbAkte.getColumn("aId")));
        bc.addPart(result.newColumnReference(t2.getColumn(aAktenId.getName())));
        return result;
  }
View Full Code Here

      versionGenerator.setGeneratingLogging(isGeneratingLogging());
      boolean isFirstTable = true;

      for (Iterator iter = myTables.iterator();  iter.hasNext()) {
        String tableName = (String) iter.next();
        Table table = sch.getTable(tableName);
        if (table == null) {
          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) {
                throw new IllegalStateException("Primary key column " + pkColumn.getQName() +
                                                " not found in table " + table.getQName());
              }
              pkColumns.add(new Integer(columnNum));
            }
          }
          if (pkColumns.size() == 0) {
            throw new IllegalArgumentException("The table " + table.getQName() +
                                               " doesn't have a primary key.");
          }
          columnUpdater = new IdIncrementer(pkColumns);
        }
        versionGenerator.addTable(table, columnUpdater);
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.Table

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.