db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bengtson <e...@jpox.org>
Subject Re: JDOQL query problems (JPOX issues?)
Date Sat, 28 Oct 2006 08:54:49 GMT
Quoting Michael Bouschen <mbo.tech@spree.de>:

> 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.
>

The query should work, but grouping on a literal has not a lot of sense. The
compiler should ignore the grouping.

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

Should work again.

> 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.
>

And should work too.


Mime
View raw message