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 08:48:14 GMT
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