Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 35361 invoked from network); 29 May 2006 08:18:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 May 2006 08:18:16 -0000 Received: (qmail 73085 invoked by uid 500); 29 May 2006 08:18:16 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 73054 invoked by uid 500); 29 May 2006 08:18:15 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 73031 invoked by uid 99); 29 May 2006 08:18:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 May 2006 01:18:15 -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 [217.24.207.26] (HELO mail.seitenbau.net) (217.24.207.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 May 2006 01:18:14 -0700 Received: from [192.168.15.18] (helo=www.seitenbau.net) by router.seitenbau.net with esmtp (Exim 4.43) id 1Fkcwi-0006Vr-MI for torque-dev@db.apache.org; Mon, 29 May 2006 10:17:52 +0200 In-Reply-To: Subject: AW: Copying Torque Object To: "Apache Torque Developers List" X-Mailer: Lotus Notes Release 6.5 September 26, 2003 Message-ID: From: Thomas Fischer Date: Mon, 29 May 2006 10:17:51 +0200 X-MIMETrack: Serialize by Router on www/seitenbau(Release 7.0.1|January 17, 2006) at 29.05.2006 10:17:51 AM MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N It would help me not to forget it :-) Thanks in advance, Thomas "Thoralf Rickert" schrieb am 29.05.2006 08:50:15: > Is it useful to make a "feature request" in JIRA? > > > -----Urspr=FCngliche Nachricht----- > > Von: Thoralf Rickert [mailto:thoralf.rickert@cadooz.de] > > Gesendet: Mittwoch, 24. Mai 2006 15:13 > > An: Apache Torque Developers List > > Betreff: Copying Torque Object > > > > > > Hi! > > > > I've a small problem with the copy() and copyInto() methods > > in the generated Torque objects. I've tables with > > dependencies from other tables (for example a table "login" > > which has a foreign key to a table "address"). I want to use > > the BaseAddress.copy() method to copy the address object and > > save it. If I use this method, it also loads and copies > > internally all logins which are linked to the source address > > to the new address. So, it makes a deep copy. Is it possible, > > to override this behaviour outside the Base* class without > > creating a totally new > > copy() method? I don't think so... > > > > I've noticed this some time a go and wrote my own copy() > > method in the extended Address class like this: > > > > public Address copy(boolean deepcopy) throws Exception { > > if (deepcopy) > > return super.copy(); > > else { > > Address newAddress =3D new Address(); > > newAddress.setFirstname(firstname); > > .... > > return newAddress; > > } > > } > > > > But after a little while I've added a new column to the > > address table and forgot to update the new copy() method too. > > So I didn't copy all data, if I use copy(false) - which takes > > some time to find and fix. I can't make a deep copy because > > there could be many thousands of referer rows to an address. > > I just want to copy the address data. > > > > So, the best way would be, that this copy(boolean) method > > should be added during BaseAddress generation in that class. > > I think, it's not very complicated to add this "feature". > > Here is my proposal: > > > > 1. add in Object.vm a new boolean parameter to copy() like this > > public $table.JavaName copy(boolean deepcopy) throws > > TorqueException > > { > > return copyInto(new ${table.JavaName}(),deepcopy); > > } > > 2. create two new downwards compatible methods copy() and copyInto(= ) > > public $table.JavaName copy() throws TorqueException > > { > > return copy(true); > > } > > protected $table.JavaName copyInto($table.JavaName > > copyObj) throws TorqueException > > { > > return copyInto(copyObject, true); > > } > > 3. add a new parameter deepcopy to the old copyInto() method > > and check that variable before making the > > deepcopy. I think, it's not necessary to submit that value > > recursivly to the referers. > > protected $table.JavaName copyInto($table.JavaName > > copyObj, boolean) throws TorqueException > > { > > .... > > #if ($complexObjectModel) > > if (deepcopy) { > > #foreach ($fk in $table.Referrers) > > ... > > #end > > } > > #end > > } > > > > Is that possible or did I forgot something important? > > > > bye > > Thoralf > > > > > > > > -------------------------------------------------------------------= -- > > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org > > For additional commands, e-mail: torque-dev-help@db.apache.org > > > > > > > > > > ---------------------------------------------------------------------= > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org > For additional commands, e-mail: torque-dev-help@db.apache.org >= --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org