db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luca.fo...@sorma.com
Subject Problem with multiple criteria on the same field in delete and update
Date Mon, 19 Jan 2004 08:25:57 GMT
Hi All,
I'm using Torque 3.1 with postgresql and
i am experiencing a problem with using multiple criteria on the same field
in delete and update:

---------------------------------------------------------
table/class A

A.field1
A.field2
A.field3
---------------------------------------------------------

Criteria criteria = new Criteria();
criteria.setDbName(A.DATABASE_NAME);

Criteria.Criterion field1Equal = criteria.getNewCriterion(A.field1, value1,
Criteria.EQUAL);
Criteria.Criterion field2Equal = criteria.getNewCriterion(A.field2, value2,
Criteria.EQUAL);
Criteria.Criterion field1Greater = criteria.getNewCriterion(A.field1,
value3, Criteria.GREATER_THAN);

criteria.and( field1Greater.or(field1Equal.and(field2Equal)) );

APeer.doDelete(criteria);

This snippet produced this wrong sql:
DELETE FROM A WHERE  (A.FIELD1 > value3)

Correct SQL should be:
DELETE FROM A WHERE  (A.FIELD1 > value3 or (A.FIELD1 = value1 and A.FIELD2
= value2))


Ing. Luca Forni

SORMA S.p.a.
Corso Vinzaglio, 4 - 10121
TORINO (ITALY)
Tel. +39 011 53 33 22
http://www.sorma.com


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