| Hi Jörg, The term recursive is a bit misleading for fetch-depth, and I apologize for the confusion. The fetch-depth attribute is intended to avoid accidental loading of the entire database (or at least a large portion of it) into memory due to inadvertent loading of instances that themselves have fetch groups that load instances that have fetch groups and so forth. I referred to this as recursion simply because of fetched instances having other fetched instances. The examples could be improved to include the cases that I intended to cover. While self-referencing fields are indeed covered by the fetch-depth, other fields are covered as well. Think of the fetch-depth as the maximum number of joins in the SQL statement used to fetch the object graph in one statement. On Sep 28, 2005, at 3:29 AM, Jörg von Frantzius wrote:
class A { B myB; // default fetch-depth 1 } class B { A myA; // default fetch-depth 1 Set<C> myCs; // fetch-depth 2 } class C { B myB; // default fetch-depth 1 A myA; // fetch-depth 3 } Now, if you query class A, you will get all of the A instances that satisfy the query plus all of the B instances directly referenced by the A instances. You get no C instances because the fetch-depth of A.myB limits the results to the directly reachable B instances. If you query class B, you get 1. all of the B instances that satisfy the query; 2. plus all of the A instances directly reachable from B via the myA field (B->A) STOP 3. plus all of the C instances reachable via the B.myCs field (B->C) continue 4. plus all of the B instances reachable via the C.myB field in the C instances in 3 (B->C->B) STOP 5. plus all of the A instances reachable via the C.myA field in the C instances in 3 (B->C->A) STOP If you query class C, you get 1.All of the C instances that satisfy the query 2. plus all of the B instances directly reachable via the C.myB field in the C instances in 1 (C->B) STOP 3. plus all of the A instances directly reachable via the C.myA field in the C instances in 1 (C->A) continue 4. plus all of the B instances directly reachable via the A.myB field in the A instances in 3 (C->A->B) continue 5. plus all of the A instances directly reachable via the B.myA field in the B instances in 4 (C->A->B->A) STOP 6. plus all of the C instances directly reachable via the B.myCs field in the B instances in 4 (C->A->B->C) STOP There is no requirement that a single database operation will be used to fetch the data. An iterative datastore access strategy is also spec-compliant. Does this help clarify? I will put an example like this into the specification... Craig
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp! |
smime.p7s
Description: S/MIME cryptographic signature
