db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Founaboui Haman" <fha...@kommunity.net>
Subject Re: Help on building an sql criteria
Date Tue, 25 Nov 2003 10:10:29 GMT
Thank 1000 times Peter. Your code work fine
Have a nice day

haman

----- Original Message ----- 
From: "Peter Hamlen" <peter.hamlen@teachforamerica.org>
To: "Apache Torque Users List" <torque-user@db.apache.org>
Sent: Monday, November 24, 2003 8:21 PM
Subject: Re: Help on building an sql criteria


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


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