My enhancement proposition is to add another boolean param (loadRootRef) to
@Reference annotation. It would be usable only for recursive references (like
trees).
Let's take simple class:
@Entity
class Node {
@Reference
Node root;
@Reference
Set<Node> children;
}
Imagine we have million-node tree in database and we want to fetch one Node
only. We can use lazy = true to achieve that - but in use case where we iterate
on all nodes and do something simple on referenced nodes (for example count
children) this would produce excesive amount of queries because of lazy loading.
With loadRootRef = true param:
@Entity
class Node {
@Reference(lazy = true, loadRootRef = true)
Node root;
@Reference(lazy = true, loadRootRef = true)
Set<Node> children;
}
Morphia would load desired Node, it's root and children but would NOT load
children of children, root of root, children of root, root of children etc.
Original issue reported on code.google.com by MomotDam...@gmail.com on 23 May 2011 at 3:33
Original issue reported on code.google.com by
MomotDam...@gmail.com
on 23 May 2011 at 3:33