Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 54752 invoked from network); 10 Jun 2007 11:42:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2007 11:42:31 -0000 Received: (qmail 53243 invoked by uid 500); 10 Jun 2007 11:42:34 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 53225 invoked by uid 500); 10 Jun 2007 11:42:33 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 53215 invoked by uid 99); 10 Jun 2007 11:42:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jun 2007 04:42:33 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 10 Jun 2007 04:42:29 -0700 Received: (qmail 3233 invoked from network); 10 Jun 2007 11:42:08 -0000 Received: from unknown (HELO ?R???????P??0????IPv6:::1?) (127.0.0.1) by localhost with SMTP; 10 Jun 2007 11:42:08 -0000 Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: <4666C0BA.70201@ipasystems.co.uk> <4666D58E.2060601@ipasystems.co.uk> <4667D0D7.9090609@ipasystems.co.uk> <8D92AFAF-91D4-4451-8214-55D8478A8582@objectstyle.org> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Andrus Adamchik Subject: Re: Select Query on Table with no Primary Key Date: Sun, 10 Jun 2007 14:42:07 +0300 To: user@cayenne.apache.org X-Mailer: Apple Mail (2.752.3) X-Virus-Checked: Checked by ClamAV on apache.org > If you can navigate to a single A via a relationship, to me that > implies that you have some unique constraint by which a single A is > associated with another row. And if you have a unique constraint, > then you can use that instead of a primary key. True, and that constraint makes it possible to map a "virtual" PK in Cayenne, so having a no-pk entity doesn't buy us anything in this case. But in the remaining cases uniquing is clearly broken. This includes to-many relationships and running multiple queries with overlapping result sets. Andrus On Jun 9, 2007, at 11:27 PM, Craig L Russell wrote: > Hi Andrus, > > On Jun 7, 2007, at 11:38 PM, Andrus Adamchik wrote: > >> >> On Jun 8, 2007, at 7:01 AM, Craig L Russell wrote: >> >>> Just FYI, when JDO reads data from tables without PK, it >>> internally creates a unique id, similar to a generated PK, for >>> the objects that it reads and these ids are discarded when no >>> longer needed. The fact that the mapping is for tables without PK >>> is known by the code that creates the temporary ids. >>> >>> Craig >> >> Hi Craig, >> >> I can probably implement this in Cayenne in about 30 minutes, as >> Cayenne has a notion of "temporary id" (normally used for new >> uncommitted objects). The problem of course is uniquing. So say if >> a DB row is fetched from a table via a query, resulting in object >> A, and then later the same row is navigated to via a relationship >> from another object, resulting in a second object B, distinct from >> A. This breaks the fundamental assumption about object identity. >> So we chose not to go this way. > > If you can navigate to a single A via a relationship, to me that > implies that you have some unique constraint by which a single A is > associated with another row. And if you have a unique constraint, > then you can use that instead of a primary key. > > Craig