Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 57245 invoked from network); 28 Sep 2005 13:37:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Sep 2005 13:37:47 -0000 Received: (qmail 34475 invoked by uid 500); 28 Sep 2005 13:37:47 -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 Received: (qmail 34462 invoked by uid 99); 28 Sep 2005 13:37:47 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Sep 2005 06:37:47 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.224.30.66] (HELO service-01.spree.de) (212.224.30.66) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Sep 2005 06:37:52 -0700 Received: from [172.16.1.19] (rio.spree.de [172.16.1.19]) (authenticated bits=0) by service-01.spree.de (8.13.4/8.13.4/Debian-3) with ESMTP id j8SDbBX2013099 for ; Wed, 28 Sep 2005 15:37:12 +0200 Message-ID: <433A9C92.4020908@spree.de> Date: Wed, 28 Sep 2005 15:37:22 +0200 From: Michael Watzek Organization: Tech@Spree GmbH User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Re: Inheritance test schema 2 : "subclass-table" and "identity" strategy References: <200509271956.08562.andy@jpox.org> In-Reply-To: <200509271956.08562.andy@jpox.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Andy, > The Schema 2 inheritance test provokes a question regarding > autoassign/identity strategy when using "subclass-table" strategy. We have 3 > classes Employee, PartTimeEmployee, FullTimeEmployee. The Employee class uses > "subclass-table" and the 2 subclasses use "new-table" inheritance strategy. > This maps to 2 tables in the datastore > > CREATE TABLE fulltimeemployees > ( > DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, > ... > ) > > CREATE TABLE parttimeemployees > ( > DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, > ... > ) > > OK, so what's the problem ? > > Well, the problem is that "identity" strategy has been specifed in the ORM > file for both of these subclasses (and the DATASTORE_IDENTITY column is > IDENTITY too). This means that when we persist a FullTimeEmployee, an object > is inserted into "fulltimeemployees" and could be given id 1 (by the > datastore, since it is effectively managing "identity" strategy), and when we > insert a PartTimeEmployee, an object is inserted into "parttimeemployees" and > this could also be given id 1 (since the datastore manages that tables ids > too) !!! The "IDENTITY" keyword is managing ids for that RDBMS table only. > This would break many things. If I call getObjectById() passing in Employee, > and id value of 1 it wouldn't know which subclass it should use if we have DB > entries for a FullTimeEmployee (1) and a PartTimeEmployee (1). I'm not sure what you mean by "getObjectById() passing in Employee". The object model specifies that class Employee is abstract. Thus, there cannot exist persistent instances of Employee which are not instances of Employee subclasses. This means that there are no object id instances of class Employee. Maybe you mean that two datastore objectid instances, one for FullTimeEmployee and the other for PartTimeEmployee, having the same value in the database wrt their identity columns (e.g. 1) would equal in the object model? Regards, Michael > > Is the JDO impl supposed to guarantee uniqueness of ids in this situation ? > How ? For the case of the TCK it could be changed to "increment" strategy > maybe and then the JDO impl could manage these values itself perhaps. In the > real world the JDO impl could throw an exception in this situation (where > there is no "base" table that is effectively used to provide uniqueness of > ids in the inheritance tree) > > Comments ? > -- ------------------------------------------------------------------- Michael Watzek Tech@Spree Engineering GmbH mailto:mwa.tech@spree.de Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ -------------------------------------------------------------------