Package org.apache.ws.jaxme.sqls

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


      throw new IllegalStateException("The statement of the referenced table is not the same as this constraints statement.");
    }

    for (Iterator iter = pKey.getColumnLinks();  iter.hasNext()) {
      ForeignKey.ColumnLink columnReference = (ForeignKey.ColumnLink) iter.next();
      BooleanConstraint eq = createEQ();
      eq.addPart(new ColumnReferenceImpl(pReferencingTable, columnReference.getLocalColumn()));
      eq.addPart(new ColumnReferenceImpl(pReferencedTable, columnReference.getReferencedColumn()));
    }
  }
View Full Code Here


        Column referencingColumn = (Column) iter.next();
        if (!referencedIter.hasNext()) {
           throw new IllegalStateException("The size of the referencing and referenced column sets doesn't match.");
        }
        Column referencedColumn = (Column) referencedIter.next();
        BooleanConstraint eq = createEQ();
        eq.addPart(pReferencingTable.newColumnReference(referencingColumn));
        eq.addPart(pReferencedTable.newColumnReference(referencedColumn));
     }
  }
View Full Code Here

        } else {
          throw new IllegalArgumentException("Invalid part: " + o.getClass().getName());
        }
      }
    } else if (pConstraint instanceof BooleanConstraint) {
      BooleanConstraint source = (BooleanConstraint) pConstraint;
      BooleanConstraint target;
      BooleanConstraint.Type sourceType = source.getType();
      if (BooleanConstraint.Type.EQ.equals(sourceType)) {
        target = createEQ();
      } else if (BooleanConstraint.Type.NE.equals(sourceType)) {
        target = createNE();
      } else if (BooleanConstraint.Type.GT.equals(sourceType)) {
        target = createGT();
      } else if (BooleanConstraint.Type.LT.equals(sourceType)) {
        target = createLT();
      } else if (BooleanConstraint.Type.GE.equals(sourceType)) {
        target = createGE();
      } else if (BooleanConstraint.Type.LE.equals(sourceType)) {
        target = createLE();
      } else if (BooleanConstraint.Type.LIKE.equals(sourceType)) {
        target = createLIKE();
      else if (BooleanConstraint.Type.ISNULL.equals(sourceType)) {
        target = createISNULL();
      } else if (BooleanConstraint.Type.IN.equals(sourceType)) {
        target = createIN();
      } else {
        throw new IllegalArgumentException("Invalid boolean constraint type: " + sourceType);
      }
      for (Iterator iter = source.getParts();  iter.hasNext()) {
        Object o = iter.next();
        if (o instanceof Value) {
          target.addPart((Value) o);
        } else if (o instanceof ColumnReference) {
           ColumnReference colRef = (ColumnReference) o;
           TableReference tableRef = (TableReference) pMap.get(colRef.getTableReference());
           if (tableRef == null) {
             throw new IllegalStateException("Unknown reference to table " + colRef.getTableReference().getTable().getQName());
           }
           target.addPart(tableRef.newColumnReference(colRef.getColumn()));
        } else {
           throw new IllegalStateException("Unknown part type: " + o.getClass().getName());
        }
      }
    } else {
View Full Code Here

     TableReference refRef = tableReference.getRightJoinedTableReference();

     joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                                   refLocal, refRef);
     CombinedConstraint cc = statement.getWhere();
     BooleanConstraint bc = cc.createEQ();
     bc.addPart(tableReference.newColumnReference("MyIndex"));
     bc.addPlaceholder();

     SQLGenerator generator = sqlFactory.newSQLGenerator();
     generator.setLineTerminator("\n");
     String got = generator.getQuery(statement);
     String expect = "SELECT MyIndex, RefIndex, Company FROM MySchema.OtherTable JOIN MySchema.MyTable ON RefIndex=MyIndex WHERE MyIndex=?";
View Full Code Here

      if (column.isPrimaryKeyPart()) {
        selectStatement.addResultColumn(selectStatement.getTableReference().newColumnReference(refColumn));
        columns.add(deleteStatement.getTableReference().newColumnReference(column));
      }
    }
    BooleanConstraint eq = selectStatement.getWhere().createEQ();
    eq.addPart(selectStatement.getTableReference().newColumnReference("RefMyName"));
    eq.addPlaceholder();

    BooleanConstraint bc = deleteStatement.getWhere().createIN();
    bc.addPart((ColumnReference[]) columns.toArray(new ColumnReference[columns.size()]));
    bc.addPart(selectStatement);
    String expect = "DELETE FROM MySchema.MyTable WHERE (MyIndex, VerNum) IN (SELECT RefMyIndex, RefVerNum FROM MySchema.OtherTable WHERE RefMyName=?)";
    String got = gen.getQuery(deleteStatement);
    assertEquals(expect, got);
  }
View Full Code Here

    public void testConnectByPrior() {
        Table table = getBasicTable();
        OraSelectStatement selectStatement = (OraSelectStatement) table.getSelectStatement();
        SelectTableReference ref = selectStatement.getSelectTableReference();
        CombinedConstraint startWith = selectStatement.getStartWith();
        BooleanConstraint bc = startWith.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(1);
        CombinedConstraint connectByPrior = selectStatement.getConnectByPrior();
        bc = connectByPrior.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(ref.newColumnReference("MyName"));
        SQLGenerator gen = getSQLGenerator();
        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable START WITH MyIndex=1 CONNECT BY PRIOR MyIndex=MyName", query);
    }
View Full Code Here

        TableReference refRef = tableReference.getRightJoinedTableReference();
       
        joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                refLocal, refRef);
        CombinedConstraint cc = statement.getWhere();
        BooleanConstraint bc = cc.createEQ();
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        bc.addPlaceholder();
        return statement;
    }
View Full Code Here

        TableReference refRef = tableReference.getRightJoinedTableReference();
       
        joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                refLocal, refRef);
        CombinedConstraint cc = statement.getWhere();
        BooleanConstraint bc = cc.createEQ();
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        bc.addPlaceholder();
       
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        String got = generator.getQuery(statement);
        String expect = getTestLeftOuterJoinResult();
View Full Code Here

        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = table.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        SelectStatement existsStatement = otherTable.getSelectStatement();
        SelectTableReference existsTableReference = existsStatement.getSelectTableReference();
        BooleanConstraint bc = existsStatement.getWhere().createEQ();
        bc.addPart(existsTableReference.newColumnReference("RefIndex"));
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        statement.getWhere().createEXISTS(existsStatement);
       
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        String got = generator.getQuery(statement);
View Full Code Here

            if (column.isPrimaryKeyPart()) {
                selectStatement.addResultColumn(selectStatement.getTableReference().newColumnReference(refColumn));
                columns.add(deleteStatement.getTableReference().newColumnReference(column));
            }
        }
        BooleanConstraint eq = selectStatement.getWhere().createEQ();
        eq.addPart(selectStatement.getTableReference().newColumnReference("RefMyName"));
        eq.addPlaceholder();
       
        BooleanConstraint bc = deleteStatement.getWhere().createIN();
        bc.addPart((ColumnReference[]) columns.toArray(new ColumnReference[columns.size()]));
        bc.addPart(selectStatement);
        String expect = "DELETE FROM MySchema.MyTable WHERE (MyIndex, VerNum) IN ((SELECT RefMyIndex, RefVerNum FROM MySchema.OtherTable WHERE RefMyName=?))";
        String got = gen.getQuery(deleteStatement);
        assertEquals(expect, got);
    }
View Full Code Here

TOP

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

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.