db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Walding <...@walding.com>
Subject Re: Torque cannot do OR based selects
Date Fri, 10 Jan 2003 08:17:04 GMT
You're going about it the wrong way (albeit the fact that what you did 
looks right, Torque doesn't work like that)

See bottom of http://jakarta.apache.org/turbine/torque/peers-howto.html


I think something like the following (which I haven't tested or syntax 
checked) will work appropriately.  Check your logs to see what SQL is 
being run

Criteria crit = new Criteria();
Criteria.Criterion a1 = crit.getNewCriterion(BuypartsPeer.MAKE, "Honda", Criteria.EQUAL);
Criteria.Criterion b2 = crit.getNewCriterion(BuypartsPeer.PARTYEAR, 1999, Criteria.EQUAL);
crit.add(a1.or(b2));



Adam Greene wrote:

>I am trying to do the following:
>
>Criteria c2 = new Criteria();
>
>c2.add(BuypartsPeer.MAKE,"Honda");
>
>c2.or(BuypartsPeer.PARTYEAR, 1999);
>
>System.err.println(c2);
>
>try {
>
>System.out.println("List Size : " + BuypartsPeer.doSelect(c2).size());
>
>} catch (TorqueException e) {
>
>}
>
>It should print "List Size : 2" as I have one record with MAKE = Honda and
>another record where PARTYEAR = 1999, instead it prints 0.  When I check the
>Criteria (by printing it), it doesn't do an OR, but instead does an AND.  Am
>I doing something wrong or is Torque broken??
>
>
>
>--
>To unsubscribe, e-mail:   <mailto:turbine-torque-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:turbine-torque-dev-help@jakarta.apache.org>
>
>
>  
>



Mime
View raw message