db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Larsson" <def...@hotmail.com>
Subject Re: doUpdate(selectCritera, updateCriteria)
Date Mon, 08 Mar 2004 13:31:51 GMT
Ok, thanks for the pointers Kostya!

I use the default doUpdate, so therefore I was debugging
insertOrUpdateRecord
inside BasePeer.doUpdate(selectCriteria, updateCriteria).

I just couldn't figure out what BasePeer.doUpdate(selectCriteria,
updateCriteria)
was doing, so...

.I have now solved the problem with a Criteria.CUSTOM like this:

String categorySet = Cat.getCat(catId).getSetString()+"%";
String query = Constants.EMPTY_STRING;
if (selected == 0)
    query = "UPDATE Entry, Item, Cat SET Entry.SELECTED=0 WHERE Item.ID>=0
AND Cat.SETSTRING LIKE '"+categorySet+"' AND Entry.SELECTED=1 AND
Entry.SHOPID="+data.getShopId()+" AND Item.ID=Entry.ITEMID AND
Cat.ID=Entry.CATID";
else
    query = "UPDATE Entry, Item, Cat SET Entry.SELECTED=1 WHERE Item.ID>=0
AND Cat.SETSTRING LIKE '"+categorySet+"' AND Entry.SELECTED=0 AND
Entry.SHOPID="+data.getShopId()+" AND Item.ID=Entry.ITEMID AND
Cat.ID=Entry.CATID";
BasePeer.executeStatement(query);

Which is fast, but schema-dependent, so if the schema changes
I have to check this snippet every time - so if someone could enlighten me
exactly how BasePeer.doUpdate(selectCriteria, updateCriteria) parses
the selectCriteria I would much appreciate it.

> Hi Daniel,
> sorry that i cannot answer your question with a solution. All that i can
> do is to point you where the problem can be.
> Have a look at BasePeer.insertOrUpdateRecord(Record rec, String
> tableName, Criteria criteria). It takes a table name from the peer, of
> which you have called doUpdate. Then in gets all columns of this table
> and tries to find them in updateCriteria calling
> criteria.containsKey(String). If no keys were found then it throws
> TorqueException("No changes to save").
> You can try to see with your debugger what happens. Maybe the problem is
> in your implementation of doUpdate, or something else.
>
> Regards,
> Kostya

---------------------------------------------------------------------
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