You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Mark Fraser <ma...@mark100.net> on 2009/10/05 09:00:06 UTC

Prefetching and iterated queries

Using version 2.0.4....

Is it possible to use prefetching with iterated queries (or to otherwise 
achieve the same effect)?

I added prefetches to my iterated query and got the runtime excpetion:

"Iterated queries are not allowed in a batch."

I don't get this error when I don't add the prefetches so I guess what 
I'm really asking is is there a way to achieve prefetching with iterated 
queries?

Thanks

Re: Prefetching and iterated queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
You may try "joint prefetching" :

http://cayenne.apache.org/doc20/prefetching.html

This should let the query go through, and the data rows that you get  
back will contain data for the joined entity. There are a few caveats  
though:

* Cayenne 2.0 uses INNER joins for joint prefetching, potentially  
reducing the number of rows in the result. 3.0 correctly uses OUTER  
joins, and generally has better prefetching support.

* DataContext.objectFromDataRow(..) will not take prefetching into  
account, and will only instantiate the root entity. There's no  
workaround (even in 3.0) other than working with data rows without  
turning them into objects.

Andrus


On Oct 5, 2009, at 10:00 AM, Mark Fraser wrote:

> Using version 2.0.4....
>
> Is it possible to use prefetching with iterated queries (or to  
> otherwise achieve the same effect)?
>
> I added prefetches to my iterated query and got the runtime excpetion:
>
> "Iterated queries are not allowed in a batch."
>
> I don't get this error when I don't add the prefetches so I guess  
> what I'm really asking is is there a way to achieve prefetching with  
> iterated queries?
>
> Thanks
>