Andrus, thanks for your reply.

> So is named query mapped via the Modeler or do you add it in the code?

The query is mapped via the Modeler, but it's not shared across DataContexts. 
Cloning the query doesn't change anything - the exception is thrown again.
In the mapping, the checkbox "Fetch Data Objects" is disabled - perhaps this is 
the cause for the empty root ?

> In the meantime you can use a workaround:
>
>   localQuery.setRoot("MyEntity");

This solves the problem, unfortunately the SQL-Script is more complex - the 
result contains additional information which is lost after setting the root.

> Care to log a bug report in Jira?

never done that before, but I'll do my very best... ;-)

Jens
-------- Original-Nachricht --------
Betreff:     Re: SQLTemplate and setPageSize()
Datum:     Wed, 6 Aug 2008 11:26:00 -0400
Von:     Andrus Adamchik <[EMAIL PROTECTED]>
An:     [email protected]



<div class="moz-text-flowed" style="font-family: -moz-fixed">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
>

</div>


-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Reply via email to