Examples of SelectTableReference


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

   public Iterator getSelectTableReferences() {
      return new Iterator() {
         SelectTableReference reference = getSelectTableReference();
         public boolean hasNext() { return reference != null; }
         public Object next() {
            SelectTableReference result = reference;
            reference = result.getRightJoinedTableReference();
            return result;
         }
         public void remove() {
            throw new UnsupportedOperationException();
         }
View Full Code Here

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

   */
  public void testJoin() {
     Table table = getPrimaryKeyTable();
     Table otherTable = getForeignKeyTable(table);
     SelectStatement statement = otherTable.getSelectStatement();
     SelectTableReference tableReference = statement.getSelectTableReference();
     JoinReference joinReference = tableReference.join(table);

     TableReference refLocal = tableReference;
     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);
View Full Code Here

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

    }

    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

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

    protected SelectStatement getJoinStatement() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = otherTable.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        JoinReference joinReference = tableReference.join(table);
       
        TableReference refLocal = tableReference;
        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

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

        return new OraSelectStatementMetaData(pQuery);
    }

    protected String getSelectQueryFromClause(SelectStatement pQuery, SelectStatementMetaData pData) {
        if (isOracle8Compatibility()) {
            SelectTableReference tableReference = pQuery.getSelectTableReference();
            if (tableReference == null) {
                return super.getSelectQueryFromClause(pQuery, pData);
            }
            StringBuffer sb = new StringBuffer(" FROM ");
            sb.append(getTableAlias(pData, tableReference));
            for (JoinReference joinReference = tableReference.getRightJoinedTableReference();
               joinReference != null;
               joinReference = joinReference.getRightJoinedTableReference()) {
                sb.append(", ");
                sb.append(getTableAlias(pData, joinReference));
            }
View Full Code Here

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

    protected String getSelectQueryConstraints(SelectStatement pQuery, SelectStatementMetaData pData,
                                               SelectStatementMetaData.LocalData pLocalData) {
        String result;
        if (isOracle8Compatibility()) {
            SelectTableReference tableReference = pQuery.getSelectTableReference();
            if (tableReference == null) {
                result = super.getSelectQuery(pQuery, pData);
            } else {
              StringBuffer sb = new StringBuffer();
                for (JoinReference joinReference = tableReference.getRightJoinedTableReference();
                   joinReference != null;
                   joinReference = joinReference.getRightJoinedTableReference()) {
                  OraJoinReferenceImpl oraJoin = null;
                  if (joinReference instanceof OraJoinReferenceImpl) {
                      oraJoin = (OraJoinReferenceImpl) joinReference;
View Full Code Here

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

     */
    public void testLeftOuterJoin() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = otherTable.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        JoinReference joinReference = tableReference.leftOuterJoin(table);
       
        TableReference refLocal = tableReference;
        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);
View Full Code Here

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

     */
    public void testExists() {
        Table table = getPrimaryKeyTable();
        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");
View Full Code Here

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

    }

    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%");
        CombinedConstraint or = and.createOrConstraint();
        or.setNOT(true);
        bc = or.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(1);
        SQLGenerator gen = getSQLGenerator();
        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable WHERE (MyName LIKE '%a%' AND NOT (MyIndex=1))", query);

        bc = or.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(2);
        query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable WHERE (MyName LIKE '%a%' AND (NOT (MyIndex=1 OR MyIndex=2)))", query);
    }
View Full Code Here

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

   public Iterator getSelectTableReferences() {
      return new Iterator() {
         SelectTableReference reference = getSelectTableReference();
         public boolean hasNext() { return reference != null; }
         public Object next() {
            SelectTableReference result = reference;
            reference = result.getRightJoinedTableReference();
            return result;
         }
         public void remove() {
            throw new UnsupportedOperationException();
         }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.