From torque-dev-return-4219-apmail-db-torque-dev-archive=db.apache.org@db.apache.org Thu Jun 17 06:46:26 2004 Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 48847 invoked from network); 17 Jun 2004 06:46:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 17 Jun 2004 06:46:26 -0000 Received: (qmail 79163 invoked by uid 500); 17 Jun 2004 06:46:59 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 79132 invoked by uid 500); 17 Jun 2004 06:46:58 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: 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 79106 invoked by uid 99); 17 Jun 2004 06:46:58 -0000 Received: from [62.52.27.101] (HELO demdwug7.mediaways.net) (62.52.27.101) by apache.org (qpsmtpd/0.27.1) with SMTP; Wed, 16 Jun 2004 23:46:58 -0700 Received: (qmail 13815 invoked by uid 4219); 17 Jun 2004 06:46:04 -0000 Received: from desws072.mediaways.net (HELO compuserve.de) (62.52.27.28) by demdwug7.mediaways.net with SMTP; 17 Jun 2004 06:46:04 -0000 From: To: "Apache Torque Developers List" Message-ID: <36ac4340ad.340ad36ac4@compuserve.de> Date: Thu, 17 Jun 2004 08:46:04 +0200 X-Mailer: Netscape Webmail MIME-Version: 1.0 Content-Language: de Subject: Re: need help X-Accept-Language: de Content-Type: multipart/mixed; boundary="--25c71d5726483220" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ----25c71d5726483220 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 7bit Hi William! The problem is that you're updating the primary key. You call something like emailObj.setEmail("xyz@xyz.com"). The old EMail-Address is overwritten and not longer present. If you now call emailObj.save() a update will be performed due to emailObj.isNew() returns false. Torque will generate a SQL statement like "UPDATE EMAIL SET ... WHERE EMAIL.EMAIL = "xyz@xyz.com". This update will fail because no such row will be found in your database. You will have to do a doUpdate yourself. Here's an example for solving your problem: Criteria value = new Criteria(); value.add(EMailPeer.EMAIL, "xyz@xyz.com"); Criteria selection = new Criteria(); selection.add(EMailPeer.EMAIL, currentEMail.getEMail()); EMailPeer.doUpdate(selection, value); Hope this helps. F. Fray P.S. Be aware of changing a primary key! Not only referential integrity in your database must be guaranteed by you application, but the identity of your eMail object will change also. You should take a minute to think about choosing an eMail-address as primary key of a table. In most cases a numeric identifier will be the first choice. ----- Originalnachricht ----- Von: "??(William)" Datum: Donnerstag, 17. Juni 2004 1:58 am Betreff: need help > > Hi All, > > I need help. > > I set email as a table' primary key, can I modify this field > through Torque save() method. > > looks it don't work, when I first retrive obj from old email > primary key, then I change email field using setEmail() method, > > at last, obj.save(), but it doesn't replace email field with new > data. > > Could anyone tell me what the problem is ? > > > William > > > > > ------------------------------------------------------------------- > -- > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org > For additional commands, e-mail: torque-dev-help@db.apache.org > > ----25c71d5726483220 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org ----25c71d5726483220--