Sorry never tried that, I only now that is not the way the Criteria
class is meant to be used.
So I let developers talk about that.
Alternatively you can dig into the peer classes source code: I have done
a few times to understand Torque behaviour and is quite well written and
readable

Ludwig Magnusson ha scritto:
> Yes that works, but that was not what I asked.
> My question was, how can the methods and(), add() and or() all generate the
> same result?
>
> -----Original Message-----
> From: Ivano Luberti [mailto:lube...@archicoop.it] 
> Sent: den 5 februari 2010 14:10
> To: Apache Torque Users List
> Subject: Re: Criteria.or not working?
>
> If you want to combine clauses mixinn and and or operators you should
> use Criterion.
>
> Look here for an introduction to how build queries using Criteria and
> Criterion
>
> http://db.apache.org/torque/releases/torque-3.3/runtime/reference/read-from-
> db.html
>
> Ludwig Magnusson ha scritto:
>   
>> Hi!
>>
>> I have done some testing during development of a project here and it seems
>> that criteria.and([parameters]), criteria.add([parameters]) and
>> criteria.or([parameters]) all generate the same query to the database.
>>
>>  
>>
>> E.g these three code snippets:
>>
>> Criteria criteria = new Criteria();
>>
>> criteria.and("user.first_name", "John");
>>
>> criteria.and("user.last_name", "Doe");
>>
>> UserPeer.doSelect(criteria);
>>
>>  
>>
>> Criteria criteria = new Criteria();
>>
>> criteria.add("user.first_name", "John");
>>
>> criteria.add("user.last_name", "Doe");
>>
>> UserPeer.doSelect(criteria);
>>
>>  
>>
>> Criteria criteria = new Criteria();
>>
>> criteria.or("user.first_name", "John");
>>
>> criteria.or("user.last_name", "Doe");
>>
>> UserPeer.doSelect(criteria);
>>
>>  
>>
>> . would all generate the Sql query
>>
>> SELECT * FROM USER WHERE first_name = "John" AND last_name = "Doe";
>>
>>  
>>
>> How can this be?
>>
>> /Ludwig
>>
>>
>>   
>>     
>
>   

-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================


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

Reply via email to