Thomas,


Thanks for your response. Can you then tell me why the BasePeer class has a function called as static void doUpdate(Criteria, Criteria)? I am not able to understand what this function is useful for.

Thanks!
RG

From: "Hartwig, Thomas" <[EMAIL PROTECTED]>
Reply-To: "Apache Torque Users List" <[EMAIL PROTECTED]>
To: Apache Torque Users List <[EMAIL PROTECTED]>
Subject: Re: Question abour updates
Date: Fri, 23 Jan 2004 10:02:15 +0100

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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Rethink your business approach for the new year with the helpful tips here. http://special.msn.com/bcentral/prep04.armx



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to