Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 11410 invoked from network); 16 Dec 2005 16:57:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Dec 2005 16:57:51 -0000 Received: (qmail 45240 invoked by uid 500); 16 Dec 2005 16:57:42 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Delivered-To: moderator for jdo-dev@db.apache.org Received: (qmail 78954 invoked by uid 99); 16 Dec 2005 16:29:01 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of Marco@nightlabs.de designates 195.226.109.88 as permitted sender) Message-ID: <43A2EB31.5040204@NightLabs.de> Date: Fri, 16 Dec 2005 17:28:33 +0100 From: Marco Schulze User-Agent: Mozilla Thunderbird 1.0 (X11/20041207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: fetch-depth + recursion-depth Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at nightlabs.de X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Dear JDO Expert Group, may we kindly request an extension of the JDO spec: Additionally to "fetch-depth", there should be a "recursion-depth" declarable per field within a fetch-group. I'd like to explain what I mean with a little use-case: Imagine, we've got the following classes: class City { List factories; List shops; } class Factory { City city; List cars; } class Car { List factories; List shops; } class Shop { City city; List cars; } ...and we're using an EJB (or whatever backend-object) with the following methods: Factory getFactory(FactoryID id, String[] fetchGroups); Car getCar(CarID id, String[] fetchGroups); Shop getShop(ShopID id, String[] fetchGroups); Now, we first imagine, we have a "recursion-depth" available. This "recursion-depth" is not counted relative to the absolute root of the object graph (like the fetch-depth), but only when the same field of the same class is recursively passed by the detach-process. In order to give the client the maximal flexibility to get object graphs shaped in whatever form he wants, we simply need the following fetch-groups: * City.factories * City.this * Factory.city * Factory.cars * Factory.this (contains all fields) * Car.factories * Car.shops * Car.this (contains all fields) * Shop.city * Shop.cars * Shop.this (contains all fields) All of these fetch-groups would be declared with fetch-depth=0 and recursion-depth=1. But then, let's assume we have no "recursion-depth" (as it is currently the case) and only a "fetch-depth", which is counted relative to the root of the object graph. In order to give the client the same flexibility, we need many more fetch-groups: Fetch Group | Fetch-Depth | Possible Object Graphs -------------------------------|---------------------------------- City.factories_1 | 1 | City => Factory ------------------------------------------------------------------ City.factories_2 | 2 | Shop => City => Factory | | Factory => City => Factory ------------------------------------------------------------------ City.factories_3 | 3 | Car => Factory => City => Factory | | Car => Shop => City => Factory ------------------------------------------------------------------ City.shops_1 | 1 | City => Shop ------------------------------------------------------------------ City.shops_2 | 2 | Factory => City => Shop | | Shop => City => Shop ------------------------------------------------------------------ City.shops_3 | 3 | Car => Factory => City => Shop | | City => Factory => City => Shop | | Car => Shop => City => Shop | | City => Shop => City => Shop ------------------------------------------------------------------ Factory.city_1 | 1 | Factory => City ------------------------------------------------------------------ Factory.city_2 | 2 | City => Factory => City | | Car => Factory => City ------------------------------------------------------------------ Factory.city_3 | 3 | Shop => City => Factory => City | | Factory => City => Factory => City | | Shop => Car => Factory => City | | Factory => Car => Factory => City ------------------------------------------------------------------ MANY MANY MORE | | I hope by this - still quite simple - use case, it becomes already obvious, that the number of necessary fetch-groups explodes. We need for every possible graph size one more fetch-group per field. This is really a lot! The alternative would be to only define those fetch-groups that are currently needed, but then the backend has to be changed whenever the front-end needs different object graphs - and IMHO this would be bad design. I see the following possibilities: * Add "recursion-depth" to the spec and have the detach-process stop detaching whenever the first limit (fetch-depth or recursion-depth) has been reached for a field. * Make "fetch-depth" to what I named "recursion-depth" as can already be understood from the current spec. Then it would of course be necessary to add a maximum fetch-depth to either the detachCopy method or to the fetch plan. * Leave it as it is and force either the JDO user to declare many fetch-groups (which is error-prone and unconvenient) or the JDO implementation to offer a vendor-extension. Thank you very much in advance for considering one of the first two solutions. Best regards, Marco Schulze NightLabs GmbH