Using "LIKE" in J2EE SQL Query Window
Whats the syntax to define a finder method using the SQL "LIKE" clause in J2EE in the deployment settings of an CMP entity bean...for example lets say I have an entity bean with a primary ket called "PK" and a String data member called "Titile", I've tried:
SELECT "PK" FROM "EntityBeanTable" WHERE "Title" LIKE
%?1%
but that doesn't work...any suggestions?
[401 byte] By [
huertas77] at [2007-9-26 3:52:16]

Which database are you using ? If it's MS Access then "%" won't work use "*" instead.
For Oracle DB the query would be -
SELECT "PK" FROM "EntityBeanTable" WHERE "Title" LIKE "%1%";
If it's MSAccess then the query would be -
SELECT "PK" FROM "EntityBeanTable" WHERE "Title" LIKE "*1*";
Hope this helps.
Regards,
Meenakshi
m_ab at 2007-6-29 12:39:22 >

I believe the solution may be vendor specific. i am using weblogic5.1 and i use CMP entity beans.
Now the if i want a sql with like clause, then i give in the following entries in my
weblogic-cmp-rdbms-jar.xml
<finder>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.Long</method-param>
</method-params>
<finder-query><![CDATA[ (like acctCode $0)]]></finder-query>
</finder>
for more options please refer u r vendor documentations.
regards
rajesh
What EJB server are you using. With EJB1.1, this is vendor specific. Anyway, based on SQL, your statement seems to have too many double quotes, usually table and column names are not quoted in SQL, but the string value after "LIKE" should be, for example:
SELECT PK FROM EntityBeanTable WHERE Title LIKE
"%?1%"
Try using "=" instead of LIKE first to make sure the problem is really with LIKE or something else.
BTW with EJB2.0, it is standardized by EJB-QL.
yilin at 2007-6-29 12:39:22 >
