Hi,

I'm having problems running JDOQL queries that group by a variable. I think the queries below are valid, but I would like to double check this. If you agree that the queries are valid JDOQL, I will check the TCK to add these queries to existing TCK tests or add new test cases. I tried the queries with JPOX version 1.1.3 and with the nightly build from Oct 27 (no difference). I will send a test case to reproduce the problem to Erik and Andy, since I cannot attach archives here.

The class model is simple: pc class A has a field stringCol which is a collection of strings and another field bCol which is a collection of instances of class B.

The following query groups the class A instances by the strings in their string collection:
 Query q = pm.newQuery(A.class);
 q.declareVariables("java.lang.String str");
 q.setFilter("this.stringCol.contains(str)");
 q.setGrouping("str");
 q.setResult("str");
This results in an exception:
JDOUserException: Unable to find the field "str" in the candidate class. It is possible that this field is a field in a subclass, but it is illegal to reference fields directly when they are in a subclass.

I get a different exception when adding an aggregate to the result clause
 q.setResult("str, count(this)");
 JDOUserException: Unconstrained variable referenced: str

The behavior is different when iterating a collection of pc instances:
  Query q = pm.newQuery(A.class);
  q.declareVariables("model.B b");
  q.setFilter("this.bCol.contains(b)");
  q.setGrouping("b");
  q.setResult("count(this), b");
This results in:
JDOUserException: The result clause has a field expression "UnboundVariable "UNBOUND_B.ID"" that doesnt appear in the grouping. Any result specification has to be present in the grouping when grouping is specified.

Any help is appreciated. Thanks!

Regards Michael

--
Michael Bouschen                [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED]        http://www.tech.spree.de/
Tel.:++49/30/235 520-33         Buelowstr. 66                   
Fax.:++49/30/2175 2012          D-10783 Berlin                  

Reply via email to