turbine-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Bachelder" <cho...@chowda.net>
Subject Re: Criteria and where clause
Date Sun, 28 Oct 2001 23:01:36 GMT
this is how I hacked it... works now...

keyword = "%" + keyword + "%";
Criteria crit = new Criteria();
Criteria.Criterion criterion = null;
criterion = crit.getNewCriterion(FIRST_NAME, (Object)keyword, Criteria.LIKE)
                 .or(crit.getNewCriterion(LAST_NAME, (Object)keyword,
Criteria.LIKE))
                 .or(crit.getNewCriterion(MIDDLE_I, (Object)keyword,
Criteria.LIKE));
crit.and(criterion);

----- Original Message -----
From: "Dan Bachelder" <chowda@chowda.net>
To: <turbine-user@jakarta.apache.org>
Sent: Sunday, October 28, 2001 5:23 PM
Subject: Criteria and where clause


> a criteria created like this:
>
> crit = crit.or(LAST_NAME, (Object)keyword, Criteria.LIKE)
>               .or(FIRST_NAME, (Object)keyword, Criteria.LIKE)
>               .or(MIDDLE_I, (Object)keyword, Criteria.LIKE);
>
> and keyword.equals("a") gives me the following where clause....
>
> WHERE (CONTACT.LAST_NAME = 'a') AND (CONTACT.MIDDLE_I = 'a') AND
> (CONTACT.FIRST_NAME = 'a')
>
> what I want to see is:
>
> WHERE (CONTACT.LAST_NAME LIKE '%a%') OR (CONTACT.MIDDLE_I LIKE '%a%') OR
> (CONTACT.FIRST_NAME LIKE '%a%')
>
> I assumed Criteria.or() use the OR logical operator instead of the AND...
I
> also assumed Criteria.LIKE would use the LIKE operator... where have I
gone
> wrong?
>
> thanks,
> dan
>
>
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message