You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Don Vawter <do...@vawter.com> on 2004/09/24 16:32:16 UTC

doDelete and Criteria failing (2nd request)

I have been having trouble with mail filters. If I missed a response I 
apologize.

I am attempting to delete records with the constraint
DAILYDATE >= start
and
DAILYDATE <= stop
I
I have the following code

   Criteria crit = new Criteria();

           Criterion a1 = 
crit.getNewCriterion(TblDailydataPeer.DAILYDATE,start.getTime(),Criteria.GREATER_EQUAL); 

           Criterion a2= 
crit.getNewCriterion(TblDailydataPeer.DAILYDATE,stop.getTime(),Criteria.LESS_EQUAL); 

           crit.add(a1.and(a2));
           logger.debug("Criteria is "+crit);
           TblDailydataPeer.doDelete(crit);
 /*       ArrayList aList= (ArrayList)            
TblDailydataPeer.doSelect(crit);
           Iterator it = aList.iterator();
           while(it.hasNext()){
               TblDailydata td = (TblDailydata) it.next();
               TblDailydataPeer.doDelete(td);
           }
*/
The doDelete picks up the first date but not the second (see the log)
a doSelect picks up both (see the log)

LOG

DEBUG,2004-09-21 
12:04:23,com.vawter.omreporting.utility.DatabaseUpdate,Criteria is 
Criteria:: 
tbl_DailyData.DAILYDATE<=>(tbl_DailyData.DAILYDATE>='20040112000000' AND 
tbl_DailyData.DAILYDATE<='20050101000000'):
Current Query SQL (may not be complete or applicable): SELECT  FROM 
tbl_DailyData WHERE (tbl_DailyData.DAILYDATE>='20040112000000' AND 
tbl_DailyData.DAILYDATE<='20050101000000')
DEBUG,2004-09-21 
12:04:23,org.apache.torque.util.BasePeer,BasePeer.doDelete: 
whereClause=DAILYDATE>='20040112000000'

I  can work around this by commenting out the doDelete and substituring 
the commented out code above
which does the select and then deletes the row but I wouldn't think this 
should be necessary. Any clue as to why the entire criteria is not used 
and/or how to construct a criteria which will work?




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org