You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Tore Halset <ha...@pvv.ntnu.no> on 2007/10/22 13:26:34 UTC

auto-prefetch in a toMany?

Hello.

We have a to-many relationship that is used all over the application.  
Each time someone goes over that to-many relationship they want to  
take a look at the next to-many relationship as well.

A <-->> B <-->> C

To make this faster, I want to prefetch the relationship from B to C  
each time someone goes from A to B.

Is this possible by just overriding A.getBs() without loosing the  
positive sides of faulting? I think I want the ToManyList to use  
prefetches in its underlying SelectQuery.

Regards,
  - Tore.

Re: auto-prefetch in a toMany?

Posted by Kevin Menard <km...@servprise.com>.
On 10/22/07 1:24 PM, "Andrus Adamchik" <an...@objectstyle.org> wrote:

> On Oct 22, 2007, at 6:26 PM, Craig L Russell wrote:
> 
>> There is an explicit "fetch join" in JPA queries that you can use
>> to explicitly eagerly fetch related entities.
> 
> Absolutely right, I stand corrected. Sometimes it's hard to keep the
> entire Cayenne-to-JPA concept dictionary in memory :-)

Persist it to Confluence ;-)

-- 
Kevin


Re: auto-prefetch in a toMany?

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Oct 22, 2007, at 6:26 PM, Craig L Russell wrote:

> There is an explicit "fetch join" in JPA queries that you can use  
> to explicitly eagerly fetch related entities.

Absolutely right, I stand corrected. Sometimes it's hard to keep the  
entire Cayenne-to-JPA concept dictionary in memory :-)

Andrus

Re: auto-prefetch in a toMany?

Posted by Craig L Russell <Cr...@Sun.COM>.
On Oct 22, 2007, at 4:39 AM, Andrus Adamchik wrote:

> Actually JPA allows to specify that certain relationships are  
> always "eagerly fetched"

true

> (although it doesn't have a concept of prefetching in the queries)...

There is an explicit "fetch join" in JPA queries that you can use to  
explicitly eagerly fetch related entities.

Craig

> I haven't thought yet how we may handle that in Cayenne, but that  
> feature is essentially what you are asking for. (But of course  
> it'll be quicker to hack the getter, like you suggested).
>
> Andrus
>
> On Oct 22, 2007, at 2:26 PM, Tore Halset wrote:
>> Hello.
>>
>> We have a to-many relationship that is used all over the  
>> application. Each time someone goes over that to-many relationship  
>> they want to take a look at the next to-many relationship as well.
>>
>> A <-->> B <-->> C
>>
>> To make this faster, I want to prefetch the relationship from B to  
>> C each time someone goes from A to B.
>>
>> Is this possible by just overriding A.getBs() without loosing the  
>> positive sides of faulting? I think I want the ToManyList to use  
>> prefetches in its underlying SelectQuery.
>>
>> Regards,
>>  - Tore.
>>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: auto-prefetch in a toMany?

Posted by Andrus Adamchik <an...@objectstyle.org>.
Actually JPA allows to specify that certain relationships are always  
"eagerly fetched" (although it doesn't have a concept of prefetching  
in the queries)... I haven't thought yet how we may handle that in  
Cayenne, but that feature is essentially what you are asking for.  
(But of course it'll be quicker to hack the getter, like you suggested).

Andrus

On Oct 22, 2007, at 2:26 PM, Tore Halset wrote:
> Hello.
>
> We have a to-many relationship that is used all over the  
> application. Each time someone goes over that to-many relationship  
> they want to take a look at the next to-many relationship as well.
>
> A <-->> B <-->> C
>
> To make this faster, I want to prefetch the relationship from B to  
> C each time someone goes from A to B.
>
> Is this possible by just overriding A.getBs() without loosing the  
> positive sides of faulting? I think I want the ToManyList to use  
> prefetches in its underlying SelectQuery.
>
> Regards,
>  - Tore.
>