db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vitzethum, Daniel" <Daniel.Vitzet...@gigatronik.com>
Subject AW: Criteria: several columns OR-combined??
Date Mon, 07 Mar 2005 13:32:36 GMT
Hello all,

look at the "Peers HowTo":
http://db.apache.org/torque/peers-howto.html

--snip--
This is an example of a complex SQL query and the code you should use
to create it: 

select * from abc where (a < 1 and b > 2) or (a > 5 and b < 3)


Criteria crit = new Criteria();
Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1,
Criteria.LESS_THAN);
Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2,
Criteria.GREATER_THAN);
Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5,
Criteria.GREATER_THAN);
Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3,
Criteria.LESS_THAN);

crit.add(a1.and(b2).or(a5.and(b3)));
--snip--

HTH,

Daniel

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