db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramesh Sabeti" ...@reazon.com>
Subject RE: How to update multiple rows
Date Tue, 11 Nov 2003 21:13:46 GMT
To add more to the confusion, JavaDocs for BasePeer.doUpdate(Criteria
updateValues) says:

"Convenience method used to update rows in the DB. Checks if a single
int primary key is specified in the Criteria object and uses it to
perform the udpate. If no primary key is specified an Exception will be
thrown."

It seems to me that this only works on a single row with the specified
PK value.  What am I missing?

> -----Original Message-----
> From: Bill Leng [mailto:wleng@metatomix.com]
> Sent: Tuesday, November 11, 2003 1:05 PM
> To: Apache Torque Users List
> Subject: Re: How to update multiple rows
> 
> Without a primary key, I guess, you can not use the example to update.
> If the primary key contains multiple columns, you need to specify all
of
> them. Hope this helps.
> 
> Ramesh Sabeti wrote:
> 
> >I understand that.  I can't explain how the example works.  Looking
at
> >it, I'd say that both c.add(...) calls add the criteria to the WHERE
> >clause.  How do you interpret it?
> >
> >Criteria c = new Criteria();
> >c.add(BookPeer.BOOK_PRICE, 0);
> >c.add(BookPeer.BOOK_ID, 100, Criteria.LESS_THAN);
> >BasePeer.doUpdate(c);
> >
> >
> >
> >>-----Original Message-----
> >>From: Tulsi Das [mailto:quixote_arg@yahoo.com]
> >>Sent: Tuesday, November 11, 2003 12:53 PM
> >>To: Apache Torque Users List
> >>Subject: RE: How to update multiple rows
> >>
> >>The criteria is just a hashtable extension to store all the
mappings,
> >>later on, when calling the methods, the SQL generator knows where to
> >>insert them ( if you are lucky ;) )
> >>
> >>tulsi
> >>
> >> --- Ramesh Sabeti <rs@reazon.com> escribió:
> >>
> >>
> >>>I meant in the example provided by Bill.  If you set the criteria
as
> >>>suggested, Torque would use it in the WHERE clause and not in the
> >>>
> >>>
> >SET
> >
> >
> >>>clause, right?
> >>>
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Tulsi Das [mailto:quixote_arg@yahoo.com]
> >>>>Sent: Tuesday, November 11, 2003 12:45 PM
> >>>>To: Apache Torque Users List
> >>>>Subject: RE: How to update multiple rows
> >>>>
> >>>>It doesn´t know untill you call
> >>>>
> >>>>doSelect()
> >>>>or
> >>>>doUpdate()
> >>>>or even
> >>>>doDelete() methods
> >>>>
> >>>>that´s why it´s only called "Criteria"
> >>>>
> >>>>regards
> >>>>
> >>>>Tulsi
> >>>>
> >>>> --- Ramesh Sabeti <rs@reazon.com> escribió:
> >>>>
> >>>>
> >>>>>How does torque know that c.add(BookPeer.BOOK_PRICE, 0) is to
> >>>>>
> >>>>>
> >SET
> >
> >
> >>>a
> >>>
> >>>
> >>>>>value and not for comparison purposes?
> >>>>>
> >>>>>
> >>>>>
> >>>>>>-----Original Message-----
> >>>>>>From: Bill Leng [mailto:wleng@metatomix.com]
> >>>>>>Sent: Tuesday, November 11, 2003 6:18 AM
> >>>>>>To: Apache Torque Users List
> >>>>>>Subject: Re: How to update multiple rows
> >>>>>>
> >>>>>>You can do something like this
> >>>>>>Criteria c = new Criteria();
> >>>>>>c.add(BookPeer.BOOK_PRICE, 0);
> >>>>>>c.add(BookPeer.BOOK_ID, 100, Criteria.LESS_THAN);
> >>>>>>BasePeer.doUpdate(c);
> >>>>>>
> >>>>>>Ramesh Sabeti wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>I have a very simple question: How do you do something like
> >>>>>>>
> >>>>>>>
> >>>this
> >>>
> >>>
> >>>>>with
> >>>>>
> >>>>>
> >>>>>>>Torque?
> >>>>>>>
> >>>>>>>	Update book set book_price = 0 where book_id < 100
> >>>>>>>
> >>>>>>>Wish there were more online resources.
> >>>>>>>
> >>>>>>>Thanks,
> >>>>>>>
> >>>>>>>Ramesh.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
>
>>>---------------------------------------------------------------------
> >>>
> >>>
> >>>>>>>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> >>>>>>>For additional commands, e-mail:
> >>>>>>>
> >>>>>>>
> >>>torque-user-help@db.apache.org
> >>>
> >>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>--
> >>>>>>Bill Leng
> >>>>>>Sr. Software Engineer
> >>>>>>Metatomix, Inc.
> >>>>>>Tel: (901)261-8911
> >>>>>>Fax: (901)261-8901
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >---------------------------------------------------------------------
> >
> >
> >>>>>>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
> >>>>>
> >>>>>
> >>>>>
> >>>>------------
> >>>>¡Ayudá a los chicos navegando!
> >>>>En noviembre, Yahoo! dona un plato de comida por cada nuevo
> >>>>
> >>>>
> >usuario
> >
> >
> >>>que
> >>>
> >>>
> >>>>nevegue gratis con Yahoo! Conexión.
> >>>>Conectate ya en http://conexion.yahoo.com.ar
> >>>>
> >>>>
> >>>>
> >>>>
> >---------------------------------------------------------------------
> >
> >
> >>>>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
> >>>
> >>>
> >>>
> >>------------
> >>¡Ayudá a los chicos navegando!
> >>En noviembre, Yahoo! dona un plato de comida por cada nuevo usuario
> >>
> >>
> >que
> >
> >
> >>nevegue gratis con Yahoo! Conexión.
> >>Conectate ya en http://conexion.yahoo.com.ar
> >>
>
>>---------------------------------------------------------------------
> >>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
> >
> >
> >
> 
> --
> Bill Leng
> Sr. Software Engineer
> Metatomix, Inc.
> Tel: (901)261-8911
> Fax: (901)261-8901



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message