db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Larsson" <def...@hotmail.com>
Subject doUpdate(selectCritera, updateCriteria)
Date Sun, 07 Mar 2004 17:08:23 GMT
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


Mime
View raw message