cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugi Thordarson <h...@karlmenn.is>
Subject Re: Prefetch nullifies relatinoship?
Date Wed, 13 May 2015 09:29:01 GMT
Thanks Andrus. Setting the semantics to PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS made the
relationship resolve properly (and modified the SQL to use a join rather than a separate fetch
for fetching the products). Looks like a bug, shouldn’t I report this?

And I’m generating properties in my template—I’m just using slightly modified templates
for easier conversion of my old EOF code.

Cheers,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/ <http://www.loftfar.is/>
// s. 895-6688



> On 13. maí 2015, at 09:00, Andrus Adamchik <andrus@objectstyle.org> wrote:
> 
> Actually it is performed. It is a "disjoint prefetch", so a second query is generated.
I still don't see any clues as to why the prefetch is not working, so here is a purely random
suggestion: you can try other prefetch strategies and see if that makes any difference. E.g.:
> 
>  query.addPrefetch( ProductLink.PRODUCT_KEY ).setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
> 
> or 
> 
>  query.addPrefetch( ProductLink.PRODUCT_KEY ).setSemantics(PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
> 
> (BTW, looks like you are not using 4.0 cgen templates that would generate Property objects
for each property?)
> 
> Andrus
> 
>> On May 13, 2015, at 11:48 AM, Hugi Thordarson <hugi@karlmenn.is> wrote:
>> 
>> Hi Andrus.
>> Sure, here it is. Looks like a fetch is never performed for the “products” relationship…
>> 
>> https://gist.github.com/hugith/6d0ccde4aa8877e26454
>> 
>> Thanks!
>> - hugi
>> 
>> // Hugi Thordarson
>> // http://www.loftfar.is/ <http://www.loftfar.is/>
>> // s. 895-6688
>> 
>> 
>> 
>>> On 13. maí 2015, at 08:36, Andrus Adamchik <andrus@objectstyle.org> wrote:
>>> 
>>> Can you post the generated SQL by any chance? Also is there anything special
about the relationship, or is it a simple to-one ?
>>> 
>>> Andrus
>>> 
>>>> On May 12, 2015, at 6:02 PM, Hugi Thordarson <hugi@karlmenn.is> wrote:
>>>> 
>>>> Hi all.
>>>> 
>>>> I have a weird case (using Cayenne 4.0-M2) where if I add a prefetch to a
relationship, the relationship is nullified (will contain nothing). Consider the following
code:
>>>> 
>>>> SelectQuery<ProductLink> q = SelectQuery.query( ProductLink.class );
>>>> q.addPrefetch( ProductLink.PRODUCT_KEY ); // <---- This line is the culprit
>>>> 
>>>> List<ProductLink> links = oc().select( q );
>>>> 
>>>> for( ProductLink link : links ) {
>>>> 	System.out.println( link.product() );
>>>> }
>>>> 
>>>> Without the prefetch, the “product” relationship is properly populated
for each “ProductLink” object, but if I include the prefetch, the relationship is always
null.
>>>> 
>>>> Any ideas?
>>>> 
>>>> Cheers,
>>>> - hugi
>>> 
>> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message