You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by pa...@bt.com on 2001/10/23 11:28:51 UTC
Or in Criteria
I am trying to create a query which is 'or'ing 2 different columns (col1="a"
or col2="a").
I have used criteria.or(col1,"a") followed by criteria.or(col2,"a") but it
puts an 'and' in the sql instead of an 'or'. What am I doing wrong?
Cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Or in Criteria
Posted by Colin Chalmers <co...@maxware.nl>.
try this
<snip>
Criteria crit = new Criteria();
Criteria.Criterion a1 = crit.getNewCriterion(UssPeer.USS_TYPE, "Name",
Criteria.EQUAL);
Criteria.Criterion a2 = crit.getNewCriterion(UssPeer.USS_TYPE, "Surname",
Criteria.EQUAL);
crit.add( a1.or(a2));
Vector lUssVect = UssPeer.doSelect(crit);
</snip>
hope this helps
/Colin
----- Original Message -----
From: <pa...@bt.com>
To: <tu...@jakarta.apache.org>
Sent: Tuesday, October 23, 2001 11:28 AM
Subject: Or in Criteria
> I am trying to create a query which is 'or'ing 2 different columns
(col1="a"
> or col2="a").
>
> I have used criteria.or(col1,"a") followed by criteria.or(col2,"a") but it
> puts an 'and' in the sql instead of an 'or'. What am I doing wrong?
>
> Cheers,
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Or in Criteria
Posted by Matthew Forder <fo...@ams.neth.seagate.com>.
Strangely enuff, I had exactly the same problem the other day, but then my good
friend *Colin Chalmers* showed me the light...
Criteria c = new Criteria();
Criteria.Criterion a = c.getNewCriterion(FooBarPeer.COLUMN_A, "a",
Criteria.EQUAL);
Criteria.Criterion b = c.getNewCriterion(FooBarPeer.COLUMN_B, "a",
Criteria.EQUAL);
c.add(a.or(b));
Vector r = FooBarPeer.doSelect(c);
Ta da!!
Regards,
Matt
paul.hunter@bt.com wrote:
I am trying to create a query which is 'or'ing 2 different columns (col1="a"
> or col2="a").
>
> I have used criteria.or(col1,"a") followed by criteria.or(col2,"a") but it
> puts an 'and' in the sql instead of an 'or'. What am I doing wrong?
>
> Cheers,
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
--
____ | Matthew J. Forder | Data Center Supervisor
/ / () | Seagate Techology | Tel:+31 20 316 7468
\ \ \ | Koolhovenlaan 1 | Fax:+31 20 653 5537
()_/_/ | 1119 NB Schiphol-Rijk, NL | matthew.forder@seagate.com