cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugi Thordarson <h...@karlmenn.is>
Subject Prefetching all child nodes in a tree
Date Sat, 08 Aug 2015 11:14:03 GMT
Hi all.

Let’s say an entity has a self referencing relationship, resulting in two modeled relationship
definitions in the entity called “parent” and “children” (hopefully pretty self-explanatory).

Using Cayenne, is it possible, given a record (a node in the tree) to perform a prefetch so
that all child nodes are prefetched?

I’m currently doing this (where I just go as deep as I think the tree will be) which seems
to work fine, but feels a little wonky :)

query.addPrefetch( Item.CHILDREN.joint() );
query.addPrefetch( Item.CHILDREN.dot( Item.CHILDREN ).joint() );
query.addPrefetch( Item.CHILDREN.dot( Item.CHILDREN ).dot( Item.CHILDREN ).joint() );
query.addPrefetch( Item.CHILDREN.dot( Item.CHILDREN ).dot( Item.CHILDREN ).dot( Item.CHILDREN
).joint() );

Cheers,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/ <http://www.loftfar.is/>
// s. 895-6688
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message