From torque-user-return-5619-apmail-db-torque-user-archive=db.apache.org@db.apache.org Wed Dec 08 14:11:51 2004 Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 16548 invoked from network); 8 Dec 2004 14:11:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Dec 2004 14:11:51 -0000 Received: (qmail 42150 invoked by uid 500); 8 Dec 2004 14:11:45 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 42135 invoked by uid 500); 8 Dec 2004 14:11:45 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 42122 invoked by uid 99); 8 Dec 2004 14:11:45 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.seitenbau.net (HELO mail.seitenbau.net) (194.175.229.106) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 08 Dec 2004 06:11:43 -0800 Received: from [195.127.188.18] (helo=www.seitenbau.net) by mail.seitenbau.net with esmtp (Exim 4.30) id 1Cc2XV-0002k2-OI for torque-user@db.apache.org; Wed, 08 Dec 2004 15:11:33 +0100 In-Reply-To: <9B336061971E8B4E8A324C63BEB2D2EE8C0CB5@ex1.GT.local> Subject: RE: Saving associated objects To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Thomas Fischer Date: Wed, 8 Dec 2004 15:11:33 +0100 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 08.12.2004 03:11:33 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Scan-Signature: 09e71911b854956f2b84373bca2c6c94 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Daniel, I am not sure if I understand the question. Let me pose the question in my own words: You have a 1:n relation. If you save an object on the "1" side, the related objects on the "n" side get saved. If you are on the "n" side, why is the "1" side not saved ? The "1" side is the side where no foreign key is defined (just the primary key of the objects) The "n" side is the side where objects hold an additional foreign key which references the primary key on the "1" side. I would think this behaviour is logical, as otherwise there might be more objects saved as you want (all the other objects which are related to the "1" side) If you have a real 1:1 behaviour, you can put the foreign key on the other side, then you can "save through" from the other side. As far as I know (which is not very far in this area), there is no way how you can define a "real" 1:1 relation, so you cannot expect to get saves on both sides automatically. If you do not have too many relations of this sort, a solution would be to override the save(..) methods in the persistent Objects. Thomas "Vitzethum, Daniel" schrieb am 08.12.2004 14:39:25: > Hello list, > > one more question: > > when saving, Torque's save methods just consider the associated > collections for saving, but not the single objects associated > by foreign key. > > Some code: > ---snip--- > public void save(Connection con) throws TorqueException { > (...) > if (collSomeObjects != null) > { > for (int i = 0; i < collSomeObjects.size(); i++) > { > ((SomeObject) collSomeObjects.get(i)).save(con); > } > } > (...) > } > ---snip--- > > But where is > --- > if (aOtherObject != null) { > aOtherObject.save(son); > } > --- > > Why that, and can I influence this behavior? > > > Daniel > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org