Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 67316 invoked from network); 23 Jan 2004 09:02:36 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Jan 2004 09:02:36 -0000 Received: (qmail 7227 invoked by uid 500); 23 Jan 2004 09:02:10 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 7215 invoked by uid 500); 23 Jan 2004 09:02:10 -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 7202 invoked from network); 23 Jan 2004 09:02:10 -0000 Received: from unknown (HELO mail.crapoud.com) (62.241.36.119) by daedalus.apache.org with SMTP; 23 Jan 2004 09:02:10 -0000 Received: from crapoud.com (pD9E77BB0.dip.t-dialin.net [217.231.123.176]) (authenticated bits=0) by mail.crapoud.com (8.12.8/8.12.8) with ESMTP id i0N92F8P027876 for ; Fri, 23 Jan 2004 10:02:18 +0100 Message-ID: <4010E317.50004@crapoud.com> Date: Fri, 23 Jan 2004 10:02:15 +0100 From: "Hartwig, Thomas" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en, de MIME-Version: 1.0 To: Apache Torque Users List Subject: Re: Question abour updates References: In-Reply-To: X-Enigmail-Version: 0.83.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Crapoud-MailScanner-Information: Please contact the ISP for more information X-Crapoud-MailScanner: Found to be clean X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I did not use doUpdate. I'm afraid you think still in a SQL way to much. Torque helps you to do something with objects. So the most convenient way would be: 1. Fetch the objects which meet your constraints with a doSelect(...Criteria...) 2. Modify the objects with the qualified set[Field] methods 3. Do a save on the object This does seem be a long way, but I think this would be a cleaner way in the sense of OO, however you are still free to do direct SQL queries with Torque. ;-) Greetings Thomas PS: One short tip, if you want to do something with the target table File, then use always FilePeer and not BasePeer. RG . wrote: > Hi, > I have a question about how updates work in Torque. > > Suppose, I want to do the following. > > Update table1 set value1='newPasswd' where value1='oldPasswd' and > value2='user4'; > > Now I guess, the way to do this would be to have 2 criteria's and then > call doUpdate in the BasePeer. Something like: > > // Next form the criteria to first select this user from the table. > Criteria crit1 = new Criteria(); > crit1.add(FilePeer.ID, "user4"); > crit1.add(FilePeer.PASSWORD, "oldPasswd"); > > Criteria crit2 = new Criteria(); > crit2.add(FilePeer.PASSWORD, "newPasswd"); > > BasePeer.doUpdate(crit1, crit2); // Also tried FilePeer.doUpdate > - but did'nt work :( > > When, I execute the above piece of code, I get a NullPointer Exception. > Exception in thread "main" java.lang.NullPointerException > at org.apache.torque.util.BasePeer.doUpdate(BasePeer.java:1888) > at org.apache.torque.util.BasePeer.doUpdate(BasePeer.java:1835) > > > Any suggesttions ??? > Thanks in advance. > RG. > > _________________________________________________________________ > Get a FREE online virus check for your PC here, from McAfee. > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > > --------------------------------------------------------------------- > 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