Grokbase Groups Cayenne user May 2015
Hmm, I thought I had added a validation check for that last year as I was
bitten by the same issue. Will have to revisit it.


On Wed, May 13, 2015 at 11:27 AM, Hugi Thordarson wrote:

Darn… Took a better look at the model, turns out the
“product_link.product_id" field was a string, while “” was an
integer. Changing both fields to integers resolved the issue. As I said
this morning; not enough coffee in me :).

PErhaps adding validation for matching types in relationships might be
helpful, even if it’d just emit a warning when the runtime is initialized
(or in the Modeler)? These days, EOF refuses to start up an EOF stack if
any modeled relationships have joins on different value types (unless a
property is set to explicitly allow it). I’d love to write and contribute a
check like that if you believe it would be useful.

- hugi

On 13. maí 2015, at 09:34, Andrus Adamchik wrote:

Yeah a bug report would be great. But we'll need more information to
reproduce the problem. A disjoint prefetch on to-one is the most common
case and it works of course, so there has to be something special about
your DB or your mapping. A full DataMap (or at least the part with these 2
entities) should help. If you can't expose it publicly, you can still open
a Jira, and email me the mapping privately.
On May 13, 2015, at 12:29 PM, Hugi Thordarson wrote:

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.
- hugi

// Hugi Thordarson
// <>
// s. 895-6688

On 13. maí 2015, at 09:00, Andrus Adamchik 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

query.addPrefetch( ProductLink.PRODUCT_KEY
(BTW, looks like you are not using 4.0 cgen templates that would
generate Property objects for each property?)
On May 13, 2015, at 11:48 AM, Hugi Thordarson wrote:

Hi Andrus.
Sure, here it is. Looks like a fetch is never performed for the
“products” relationship…

- hugi

// Hugi Thordarson
// <>
// s. 895-6688

On 13. maí 2015, at 08:36, Andrus Adamchik 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 ?
On May 12, 2015, at 6:02 PM, Hugi Thordarson 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
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?

- hugi

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 11 | next ›
Discussion Overview
groupuser @
postedMay 12, '15 at 3:05p
activeMay 13, '15 at 4:45p



site design / logo © 2021 Grokbase