db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bernard.n...@vallourec.fr
Subject Réf. : URGENT: Creating TWO Criteria on SINGLE column fails
Date Fri, 24 Jun 2005 06:23:24 GMT

Use and instead of add for the second condition on CREATED_DATE field.
Otherwise, the second condition will replace the first one.

Timestamp tsStart = new Timestamp(TransactionPeer.createCalendar(dateStart,
hhmm).getTimeInMillis());
myCriteria.add(TransactionPeer.CREATED_DATE, tsStart,
Criteria.GREATER_EQUAL);

Timestamp tsEnd = new Timestamp(TransactionPeer.createCalendar(dateEnd,
hhmmEnd).getTimeInMillis());
myCriteria.and(TransactionPeer.CREATED_DATE, tsEnd, Criteria.LESS_EQUAL);


if (rfidId != -1) {
           myCriteria.add(TransactionPeer.STATUS, 1, Criteria.EQUAL);

}





                                                                                         
                                
                    "Dionisius Purba"                                                    
                                
                    <Dionisius.Purba@mi        Pour :  <torque-user@db.apache.org>
                                       
                    trais.com>                 cc :                                   
                                   
                                               Objet :      URGENT: Creating TWO Criteria
on SINGLE column fails          
                    24/06/2005 06:27                                                     
                                
                    Veuillez répondre à                                                
                                  
                    "Apache Torque                                                       
                                
                    Users List"                                                          
                                
                                                                                         
                                
                                                                                         
                                




Hi, plese help, I'm a Torque's newbie.
I think I do something stupid here.

I need to create the following SQL:
select * from transaction where creation_date > ? & creation_date < ?

therefore I make the following criteria building:
Criteria myCriteria = new Criteria();

Timestamp tsStart = new Timestamp(TransactionPeer.createCalendar(dateStart,
hhmm).getTimeInMillis());
myCriteria.add(TransactionPeer.CREATED_DATE, tsStart,
Criteria.GREATER_EQUAL);

Timestamp tsEnd = new Timestamp(TransactionPeer.createCalendar(dateEnd,
hhmmEnd).getTimeInMillis());
myCriteria.add(TransactionPeer.CREATED_DATE, tsEnd, Criteria.LESS_EQUAL);


if (rfidId != -1) {
           myCriteria.add(TransactionPeer.STATUS, 1, Criteria.EQUAL);

}

You can see there are two (not one) criteria there, GREATER_EQUAL and
LESS_EQUAL
but it seems that only one of two is used as shown in the log generated by
Torque

SELECT COUNT(transaction.ID) FROM transaction WHERE
transaction.CREATED_DATE>='20050624080011' AND transaction.STATUS=1

Notice that the second criteria (STATUS) is successfully constructed, but
not the 2nd CREATED_DATE.
Please help with this quickly.
Thanks a lot in advance.

Dionisius Purba
Software Engineer

Mitrais Software Development Center
Tel : +62 361 755025
Fax: +62 361 755024
Visit our website <<<http://www.mitrais.com/>>>

This transmission is for the intended addressee only and is confidential
information.
If you have received this transmission in error, please delete it and
notify the sender.
The contents of this E-mail are the opinion of the writer only
and are not endorsed by PT MITRAIS unless expressly stated otherwise.





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