db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl ...@apache.org>
Subject Re: Problem with OR Clause
Date Fri, 11 May 2007 20:54:34 GMT
Greg Monroe wrote:
> Old version of torque so I'm not sure about this.  But my
> best guess would be that the crit.add(...) / or(..) methods
> are returning a copy of the original criteria object rather 
> than the original criteria.

The criteria methods always return the modified criteria, that is, a
reference to the original criteria, not a copy.

The problem here is that the crit.and() and crit.or() methods are meant
to combine conditions related to the same column and not to different
columns. These are always ANDed unless you use Criteria.Criterion
objects as was discussed before.


Examples:

crit.add(SomePeer.SOMECOLUMN, 2);
crit.or(SomePeer.SOMECOLUMN, 3);

will get you

WHERE (some.SOMECOLUMN = 2 or some.SOMECOLUMN = 3)

crit.add(SomePeer.SOMECOLUMN, 2, Criteria.GREATER_THAN);
crit.and(SomePeer.SOMECOLUMN, 4, Criteria.LESS_THAN);

will get you

WHERE some.SOMECOLUMN > 2 and some.SOMECOLUMN < 4)


Bye, Thomas.

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