db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Hamlen <peter.ham...@teachforamerica.org>
Subject Re: Help on building an sql criteria
Date Mon, 24 Nov 2003 19:21:23 GMT
One trick would be to use the Criteria.CUSTOM option:

Criteria crit = new Criteria();
crit.add(ArticlePeer.ARTICLENAME, (Object)"(article.name like
'%"+searchString+"%' or article.number like '%"+searchString+"%')",
Criteria.CUSTOM);

Two important notes:
1)  Be sure to cast the middle argument as an object - otherwise you'll
get an "ambiguous method call" error
2)  We're using a way-old version of Torque (3.0b2) so some of the
syntax may have changed - but I don't think so.

You can also do it in a more complicated fashion by using Criterions and
explicitly joining them, but I personally don't think it's worth the
effort.

-Peter


On Mon, 2003-11-24 at 11:09, Founaboui Haman wrote:

> Hi there,
> 
> I am looking for a way to build the following criteria in torque.
> The sql: 
> 
> SELECT * FROM articles WHERE any condition AND (articlename LIKE '%seachString%' OR articleNumber
LIKE '%searchString%');
> 
> My problem resides in the criteria between the parenthesis. Any help with code shnippet
could be appreciated.
> Thank for your help
> 
> haman

Peter Hamlen (peter.hamlen@teachforamerica.org)
Deputy Vice President, Technology 
Teach For America 
212-279-2080 ext 170
http://www.teachforamerica.org

"One day, all children in this nation will have the opportunity to
attain an excellent education."

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message