You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Steve Davis <st...@digitalevergreen.com> on 2001/07/26 05:44:01 UTC
How do I get a 'LIKE' comparison in Criteria
I am trying to do a LIKE comparison in the WHERE clause of my search.
I create my criteria like so:
String searchString = "foo";
Criteria crit = new Criteria();
crit.add("TURBINE_USER.LAST_NAME", (Object) searchString,
Criteria.LIKE );
When I do a toString() on the criteria it gives me
SELECT FROM TURBINE_USER WHERE (TURBINE_USER.LAST_NAME = 'foo')
I dug through the code and it looks like TurbineUserPeer doSelect method
feeds the BasePeer doSelect which calls createQueryString to build the
query from the criteria. I do not see anywhere in createQueryString
where it would include any comparisons.
Am I missing something. Is this the correct way to do a "LIKE"
comparison?
I think I am doing same thing that the criteria doc example shows. I am
using code from the CVS HEAD of about 3 weeks ago. It builds the
turbine-2.2-dev.jar. I would appreciate any pointers someone could give
me.
-- Steve Davis
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: How do I get a 'LIKE' comparison in Criteria
Posted by Andrea Papotti <bi...@ettelematica.it>.
try with:
criteria.add("TURBINE_USER.LAST_NAME", (Object)("TURBINE_USER.LAST_NAME LIKE
'%" + searchString+ "%'"), (String)Criteria.CUSTOM);
this is the way I used to do LIKE comparison in my apps, and it works pretty
well.
hope it's usefull, Andrea
----- Original Message -----
From: "Steve Davis" <st...@digitalevergreen.com>
To: <tu...@jakarta.apache.org>
Sent: Thursday, July 26, 2001 5:44 AM
Subject: How do I get a 'LIKE' comparison in Criteria
> I am trying to do a LIKE comparison in the WHERE clause of my search.
>
> I create my criteria like so:
>
> String searchString = "foo";
> Criteria crit = new Criteria();
> crit.add("TURBINE_USER.LAST_NAME", (Object) searchString,
> Criteria.LIKE );
>
> When I do a toString() on the criteria it gives me
>
> SELECT FROM TURBINE_USER WHERE (TURBINE_USER.LAST_NAME = 'foo')
>
> I dug through the code and it looks like TurbineUserPeer doSelect method
> feeds the BasePeer doSelect which calls createQueryString to build the
> query from the criteria. I do not see anywhere in createQueryString
> where it would include any comparisons.
>
> Am I missing something. Is this the correct way to do a "LIKE"
> comparison?
> I think I am doing same thing that the criteria doc example shows. I am
> using code from the CVS HEAD of about 3 weeks ago. It builds the
> turbine-2.2-dev.jar. I would appreciate any pointers someone could give
> me.
>
> -- Steve Davis
>
> ---------------------------------------------------------------------
> 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