public void testUntyped() throws QueryException {
    // one untyped iterator is now resolved fine
    Query q = this.qs.newQuery("SELECT DISTINCT * " + "FROM /pos " + "WHERE ID = 3 ");
    q.execute();

    // if there are two untyped iterators, then it's a problem, see bug 32251 and BugTest
    q = this.qs.newQuery("SELECT DISTINCT * FROM /pos, positions WHERE ID = 3");
    try {
      q.execute();
      fail("Expected a TypeMismatchException");
    } catch (TypeMismatchException e) {
      // pass
    }
  }
  public void testTyped() throws QueryException {
    Query q =
        this.qs.newQuery( // must quote "query" because it is a reserved word
            "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n"
                + "SELECT DISTINCT *\n"
                + "FROM /pos TYPE Portfolio\n"
                + "WHERE ID = 3  ");
    Object r = q.execute();
    CacheUtils.getLogger().fine(Utils.printResult(r));

    q =
        this.qs.newQuery( // must quote "query" because it is a reserved word
            "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n"
                + "SELECT DISTINCT *\n"
                + "FROM /pos ptfo TYPE Portfolio\n"
                + "WHERE ID = 3  ");
    r = q.execute();
    CacheUtils.getLogger().fine(Utils.printResult(r));
  }
  public void testTypeCasted() throws QueryException {
    Query q =
        this.qs.newQuery( // must quote "query" because it is a reserved word
            "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n"
                + "SELECT DISTINCT *\n"
                + "FROM (collection<Portfolio>)/pos\n"
                + "WHERE ID = 3  ");
    //
    // com.gemstone.gemfire.internal.util.DebuggerSupport.waitForJavaDebugger(this.cache.getLogger());
    Object r = q.execute();
    CacheUtils.getLogger().fine(Utils.printResult(r));

    q =
        this.qs.newQuery( // must quote "query" because it is a reserved word
            "IMPORT com.gemstone.gemfire.cache.\"query\".data.Position;\n"
                + "SELECT DISTINCT *\n"
                + "FROM /pos p, (collection<Position>)p.positions.values\n"
                + "WHERE secId = 'IBM'");
    //
    // com.gemstone.gemfire.internal.util.DebuggerSupport.waitForJavaDebugger(this.cache.getLogger());
    r = q.execute();
    CacheUtils.getLogger().fine(Utils.printResult(r));
  }
Example #4
0
  public void setUp() {
    q1 = new Query();
    Table t = new Table("mytable");
    Constant c = new Constant("1");
    Field f = new Field("a", t);
    SelectValue sv = new SelectValue(f, null);
    q1.addFrom(t);
    q1.addSelect(sv);
    q1.addWhere(new Constraint(f, Constraint.EQ, c));

    q2 = new Query();
    Table t1 = new Table("mytable");
    Table t2 = new Table("mytable");
    Field f1 = new Field("a", t1);
    Field f2 = new Field("b", t2);
    sv = new SelectValue(f1, null);
    q2.addFrom(t1);
    q2.addFrom(t2);
    q2.addSelect(sv);
    q2.addWhere(new Constraint(f1, Constraint.EQ, c));
    q2.addWhere(new Constraint(f2, Constraint.EQ, c));
  }