Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 85961 invoked from network); 8 Apr 2009 01:04:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Apr 2009 01:04:27 -0000 Received: (qmail 68626 invoked by uid 500); 8 Apr 2009 01:04:26 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 68600 invoked by uid 500); 8 Apr 2009 01:04:26 -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 68590 invoked by uid 99); 8 Apr 2009 01:04:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2009 01:04:26 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [68.142.237.108] (HELO n1.bullet.mail.re3.yahoo.com) (68.142.237.108) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Apr 2009 01:04:16 +0000 Received: from [68.142.237.89] by n1.bullet.mail.re3.yahoo.com with NNFMP; 08 Apr 2009 01:03:55 -0000 Received: from [67.195.9.83] by t5.bullet.re3.yahoo.com with NNFMP; 08 Apr 2009 01:03:55 -0000 Received: from [67.195.9.105] by t3.bullet.mail.gq1.yahoo.com with NNFMP; 08 Apr 2009 01:03:55 -0000 Received: from [127.0.0.1] by omp109.mail.gq1.yahoo.com with NNFMP; 08 Apr 2009 01:04:26 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 104086.93632.bm@omp109.mail.gq1.yahoo.com Received: (qmail 11083 invoked by uid 60001); 8 Apr 2009 01:03:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1239152635; bh=ds+wx0ey6ENZmmIzWGnTychs0hQcPBkvV3nkmo9Ser4=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=RLN6vZrbMnxmaKD4PPDod8QAjAfWee16ZX4wbHCRmkk/fVDi2ox3u5B0oK0nxEpLQTn0Ap+YwMyUYxXX+sC91g23/ogTe67IdCOACIF/Ln94VYZQM+v2NktAfZ4l3TUZR6XMtg2m92rd/VPR4HxSAK6hKqOaiAi9FqvDt2U3YoI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=hngK6dRvQx38WJMDmNI79LqNJvytpKTHpzg/gtBoPFhjBZ07S5gPIYLdvL9Q3j/iYf4m5v7qLq0Q9QqLmEQmeqSKuH3B9CDyjIEx+/IVQLar5co8xLC/vz2ApxGZZmF485ZoC32Z+oXMSUvgWzoLFF6A3bOIXcS5CvZWEL4XJj4=; Message-ID: <315763.11044.qm@web111104.mail.gq1.yahoo.com> X-YMail-OSG: F4rmLSYVM1nRxoShldqWLr9jDETE5H154zuHgUoBSdFq_mCJHI0YI5MwqDk1Ek7KobG.vfx.WxkdqgeRIUWCPQKKNSWBTpKkugy.C3ypkDdni5U8JTESsfjQimD2V.wkxlV4F5PUnwSFkWPdnxZ6Ex3LjcR8_kpICNWQn5f3kJL6YMlX7EsBgGe8HjtxdbaPogvS5euBFNov68Uxvn6IQcu92CV3NIQw17ComHNSvC0aFrP8B3enptrH_fHmTLCyDTP6r_3yc4auHCkXUAE- Received: from [84.167.240.139] by web111104.mail.gq1.yahoo.com via HTTP; Tue, 07 Apr 2009 18:03:55 PDT X-Mailer: YahooMailClassic/5.2.15 YahooMailWebService/0.7.289.1 Date: Tue, 7 Apr 2009 18:03:55 -0700 (PDT) From: Joseph Schmidt Subject: Re: "Can't get primary key from temporary id" :( To: user@cayenne.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked by ClamAV on apache.org > > Can't get primary key from temporary id > > ------------ > > > > while trying to access the 'id' of a newly created > object entity A. > > I need this 'id' to write the value together with some > > other fields in some other object entity B inside the same > > transaction. Between A and B there's no relationship (I'm > > using MySQL as a DB and CayenneM5). > > > The primary key doesn't exist until the record is written > to the database, so you just can't do this. You have two > options: > > * write the record to database, fetch it back again and > then you'll have the primary key Than this is not the same transaction :(. > * create a relationship between A and B In this particular case, there's no relationship because the 'id' from entity A is written to a text field in entity B together with other strings, e.g. "Entity A with #id added at #date..." So it's impossible to map here a relationship :(. In other usage scenarios I have, e.g. for entity C, there's no Cayenne relationship because it would mean to connect it with every other table. > If you find yourself using the primary keys directly very > often, you are probably not using Cayenne in the manner it > was intended. The idea is that it removes you from thinking > about database-centric issues like primary keys and just > think about objects and how they relate to each other. > Mostly. Well, I'm not sure about Cayenne, but the entire RESt architecture is based around the idea of using 'id's to identify entities (but not just RESt). If Cayenne can't play simply with 'id's (and it's supposed to be used without them) than I think it automatically excludes itself from most web applications :(, since most of them rely on sending the 'id's back and forth. Is there no other way to get those IDs? How to do e.g. audit with Cayenne? Mostly the audit string or record must be in the same transaction with with what they log. thanks, Joseph.