db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thijs Verhagen <thijsverha...@mac.com>
Subject Re: (postscript) Delete not working with empty criteria
Date Sun, 06 Apr 2003 13:59:15 GMT
I find it convenient while testing to empty out entire tables. It can 
be tedious to do this in sql, especially if there are dependencies.
Adding   PrimaryKey  > 0 to the criteria threw a 
com.workingdogs.village.DataSetException:
(You must specify KeyDef attributes for this TableDataSet in order to 
delete a Record.)
when I tried this on a table with idmethod=none

Eventually I settled for a call to executeStatement found in BasePeer:
...
CgroupmemberPeer.executeStatement( "delete from " + 
CgroupmemberPeer.TABLE_NAME );
PersonPeer.executeStatement( "delete from " + PersonPeer.TABLE_NAME );
...

BasePeer.executeStatement() is a direct escape to jdbc; it skips all 
the elegant o/r-mappings torque builds, so it should be avoided, but 
it's OK for testing purposes I suppose.


Hope this is helpful to someone.

gr.
Thijs

Karl Stenerud heeft op donderdag, 3 apr 2003 om 02:40 
(Europe/Amsterdam) het volgende geschreven:

> Thanks for the help.
>
> After thinking about it a bit more, I've decided that I don't have the 
> belly
> for keeping code around that deletes an entire table, even if it is 
> only for
> testing purposes =)
>
>
> 2003 4月 3 木曜日 00:47、Eric Emminger さんは書きました:
>> Karl
>>
>>> I'm trying to delete all entries in a table, but when I run the 
>>> program,
>>> nothing happens.
>>>
>>>
>>> I built the delete statement the same way I did a select all 
>>> statement:
>>>
>>>     Criteria crit = new Criteria();
>>>     AdminuserPeer.doDelete(crit);
>>>
>>> After running this, the table still has old data in it.  Is there
>>> something else I should be doing?
>>
>> I'm guessing this is a safeguard against accidentally deleting 
>> everything.
>>
>> Try adding something to your Criteria, such as
>>
>> crit.add(YourPeer.YOUR_PRIMARYKEY, 0, Criteria.GREATER_THAN);
>>
>> Eric
>>
>>
>> ---------------------------------------------------------------------
>> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message