Hi Jens,
Not quite sure why the root is null. So is named query mapped via the
Modeler or do you add it in the code?
As an aside (this may have nothing to do with your problem), all
mapped queries are shared across DataContexts, so you may have a race
condition when you attempt to modify the query in the code. So you may
want to clone the query like that:
SQLTemplate localQuery = rawQuery.queryWithParameters(...);
localQuery.setpageSize(50);
Andrus
On Aug 6, 2008, at 6:35 AM, Jens Mayer wrote:
Hi,
i'm using Cayenne 2.0.4 with Oracle 10 and JDK 1.5.
Please have a short look at this code:
... dataCtx, myID are set...
SQLTemplate rawQuery =
(SQLTemplate)dataCtx.getEntityResolver().lookupQuery("myQuery");
Map<String,Object> params = new HashMap<String,Object>();
params.put("processID", myID);
rawQuery.setParameters(params);
rawQuery.setPageSize(50);
List<?> protList = dataCtx.performQuery(rawQuery);
...
On runtime the follwoing Exception ist thrown:
java.lang.IllegalArgumentException:
org.apache.cayenne.query.SelectQuery: "setRoot(..)" takes a DataMap,
String, ObjEntity, DbEntity, Procedure, or Class. It was passed a null
at
org.apache.cayenne.query.AbstractQuery.setRoot(AbstractQuery.java:104)
at org.apache.cayenne.query.SelectQuery.init(SelectQuery.java:143)
at org.apache.cayenne.query.SelectQuery.<init>(SelectQuery.java:83)
at org.apache.cayenne.query.SelectQuery.<init>(SelectQuery.java:72)
at
org
.apache
.cayenne
.access.IncrementalFaultList.<init>(IncrementalFaultList.java:129)
at
org
.apache
.cayenne
.access
.DataContextQueryAction
.interceptPaginatedQuery(DataContextQueryAction.java:92)
at
org
.apache
.cayenne
.access.DataContextQueryAction.execute(DataContextQueryAction.java:50)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:
1395)
at
org.apache.cayenne.access.DataContext.performQuery(DataContext.java:
1384)
..... more
The mapped query is configured to fetch DataRows.
The cause seems to be the method setPageSize(): if I omit this
method, all works fine. I cannot find any restrictions for
setPageSize and SQLTemplate in the documentation.
Does anybody know what's going on here ?
Thanks in advance
Jens
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser