Please try:

     Criteria crit = new Criteria();
     Criteria.Criterion a1 = crit.getNewCriterion( SchoolsPeer.NAME,
(Object) (search), Criteria.EQUAL);
     Criteria.Criterion a2 = crit.getNewCriterion(
SchoolsPeer.SCHOOL_NUMBER, (Object) search, Criteria.EQUAL);
     crit.add( a1.or( a2 ));

Rafal



> Yes, I believe so. I'm using this:
>
>         Criteria crit = new Criteria();
>         crit.add(SchoolsPeer.NAME, (Object) (search), Criteria.EQUAL);
>         crit.or(SchoolsPeer.SCHOOL_NUMBER, (Object) search,
Criteria.EQUAL);
>
> But when the Query class is used to generate the output, it uses " AND "
as
> the delimiter between criteria. Is there another way to construct these
> Criteria?
>
> > -----Original Message-----
> > From: Howard Lin [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, October 07, 2002 3:26 PM
> > To: Turbine Torque Users List
> > Subject: RE: How to construct a WHERE clause using OR instead of AND
> > between Criteria?
> >
> >
> > Have you tried Criteria.or(...) method?
> >
> > Howard Lin
> >
> > > -----Original Message-----
> > > From: Daniel Seltzer [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, October 07, 2002 3:09 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: How to construct a WHERE clause using OR instead of
> > > AND between
> > > Criteria?
> > >
> > >
> > > I'm running 3.0-b4 and have a question about how to control
> > > the construction
> > > of the WHERE clause from Criteria. I've reviewed the docs,
> > > the archives and
> > > the source but suspect I'm missing something obvious...
> > >
> > > I'm trying to construct a simple query that looks like this:
> > >
> > >     select * from table1 where col1 = 'foo' or col2 = 'foo'
> > >
> > > But all expressions in a WHERE clause appear to be joined with AND by
> > > default, regardless of how the Criteria are added. In the source for
> > > org.apache.torque.util.Query, line 253, it looks like AND is
> > > being passed to
> > > the StringStack's toString() method as the delimiter for output:
> > >
> > >         if ( !whereCriteria.empty() )
> > >         {
> > >             stmt.append(WHERE)
> > >                 .append(whereCriteria.toString( AND ));
> > >         }
> > >
> > > Is there some other way to indicate that multiple criteria in
> > > a Query should
> > > be OR'd instead of AND'd?
> > >
> > > Thanks,
> > > Daniel
> > >
> > > ________________________________________
> > >
> > > Daniel Seltzer
> > > [EMAIL PROTECTED]
> > > www.h2co3.com
> > >
> > >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to