Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 71412 invoked from network); 6 May 2004 17:20:52 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 May 2004 17:20:52 -0000 Received: (qmail 37923 invoked by uid 500); 6 May 2004 17:20:44 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 37910 invoked by uid 500); 6 May 2004 17:20:44 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 37895 invoked from network); 6 May 2004 17:20:43 -0000 Received: from unknown (HELO pugio.net) (217.160.72.178) by daedalus.apache.org with SMTP; 6 May 2004 17:20:43 -0000 Received: from [10.0.1.5] (61-64-177-236-adsl-kao.DYNAMIC.so-net.net.tw [61.64.177.236]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by pugio.net (Postfix) with ESMTP id 8AD2D4900F2 for ; Thu, 6 May 2004 19:20:43 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v613) To: torque-user@db.apache.org Message-Id: Content-Type: multipart/alternative; boundary=Apple-Mail-1-330138696 From: Chialin Tsai Subject: Problem using doDelete with multiple criteria fields Date: Fri, 7 May 2004 01:20:37 +0800 X-Mailer: Apple Mail (2.613) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --Apple-Mail-1-330138696 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I have encountered the problem of doDelete() function is only taking the first field and ignoring the rest of fields in the criteria. I want to execute the following sql statement "DELETE FROM ATABLE WHERE ATABLE.COLUMN1=1 OR ATABLE.COLUMN2=1" by using Criteria Criterion Technique By using Criterion technique, My code is like this: Criteria criteria = new Criteria(); Criteria.Criterion criterion1 = criteria.getNewCriterion(ATABLE.COLUMN1, new Integer(1), Criteria.EQUAL); Criteria.Criterion criterion2 = criteria.getNewCriterion(ATABLE.COLUMN2, new Integer(1), Criteria.EQUAL); criteria.add(criterion1.or(criterion2)); However, doDelete() function in BasePeer only takes the first criterion as criteria for deletion and ignore the second one. I have checked the Torque log file, the where closure for doDelete() function is only the first criteria field. I also checked out the source code for doDelete() function in BasePeer. The function goes through the keyset in Criteria object and produce only one criterion. Because I used criteria.add() to add two criterions, so basically doDelete() function considers the criteria as one criteria and taking only the first part of criteria. Therefore, what actually get executed was "DELETE FROM ATABLE WHERE ATABLE.COLUMN1=1" Criteria.or() Technique Using Criteria.or() technique, I have code like: Criteria criteria = new Criteria(); criteria.add(ATABLE.COLUMN1, 1); criteria.or(ATABLE.COLUMN2, 1); I have followed the example I saw on Japanese version of Jakata project website(http://www.ad.cyberhome.ne.jp/~milmil/java/torque-search.html) By checking Torque log file, the result sql statement I actually get is: "DELETE FROM ATABLE WHERE ATABLE.COLUMN1=1 AND ATABLE.COLUMN2=1" Conclusion My conclusion is that Torque Criteria API is not able to generate a simple multiple comparisons with "OR" (gate). My current solution is to do delete separately: Criteria criteria = new Criteria(); criteria.add(ATABLE.COLUMN1, 1); doDelete(....) criteria.clear(); criteria.add(ATABLE.COLUMN2, 1); doDelete(....) Better Solution I would like to know if it is really a functionality that is not provided in Torque Criteria API or I just did not find it. If you have solution or better workaround, please let me know. Thank you. Chialin --Apple-Mail-1-330138696--