db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kostyantyn Shchekotykhin <Kostyantyn.Shchekotyk...@ifit.uni-klu.ac.at>
Subject Re: doUpdate(selectCritera, updateCriteria)
Date Mon, 08 Mar 2004 08:17:13 GMT
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


Daniel Larsson wrote:
> Noob-warning, first message ever.
> 
> I'm trying to change a bunch of (>250000 records) with
> doUpdate(selectCriteria, updateCriteria)
> like so:
> 
>      Criteria selectCriteria = new Criteria();
>      selectCriteria.add(EntryPeer.SHOPID, 1000);
>      selectCriteria.add(EntryPeer.SELECTED, 0);
> 
>       selectCriteria.addJoin(ItemPeer.ID, EntryPeer.ITEMID);
>       selectCriteria.addJoin(CatPeer.ID, EntryPeer.CATID);
>       selectCriteria.add(ItemPeer.ID, 0, Criteria.GREATER_EQUAL);
> 
>       Criteria updateCriteria = new Criteria();
>       updateCriteria.add(EntryPeer.SELECTED, 1);
> 
>       try
>       {
>          String categorySet = Cat.getCat(catId).getSetString();
>          selectCriteria.add(CatPeer.SETSTRING, (Object) (categorySet + "%"),
> Criteria.LIKE);
>          EntryPeer.doUpdate(selectCriteria, updateCriteria);
>       } catch (TorqueException e)
>       {
>       }
> 
> The doUpdate-method throws an Exception: org.apache.torque.TorqueException:
> No changes to save
> when iterating through the tables trying to insertOrUpdateRecord with Cat,
> which as you can see is
> not what I want to do. I want do flip Entry.SELECTED from 0 to 1 for Items
> with ID>0 and Cats with
> a specified SETSTRING.
> Debug output for BasePeer says:
> [BasePeer] BasePeer.doUpdate: whereClause=SETSTRING LIKE 'OTHEML%'
> .so it only takes into consideration the Cat-part of the select-clause and
> finds no changes to save.
> 
> If I comment out the two last throwTorqueException(e); in
> doUpdate(selectCriteria, updateCriteria)
> it get stuck on the Item-table and selects half a billion Items in the db.
> 
> As a workaround I will select all the 2500000 records to a List and iterate
> through them setting
> SELECTED to 1 and save(), but as you all understand that will be slow
> compared to a single
> SQL-query so I really hope someone can help me getting this doSelect to
> work.
> 
> best regards
> Daniel Larsson
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message