1 Reply Latest reply on Nov 6, 2002 5:48 PM by Daniel Hinojosa

    ejb-ql - search function

    Calvin Newbie

      I have a question in regards to the finders method that involves the "LIKE" command. In my ejb-jar.xml, i have a query as below (i.e.):


      <query-method>
      <method-name>findByVendor</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      <![CDATA[SELECT OBJECT(i) FROM T_Item i WHERE i.vendor.name LIKE '%?1%']]>
      </ejb-ql>


      This query return nothing. However, if I changed the query to <![CDATA[SELECT OBJECT(i) FROM T_Item i WHERE i.vendor.name LIKE '%Sony%']]>, then it works fine. The leads to the concerns of the usage of LIKE that I didn't have any success with. I should be able to have method parameters even using query that contains LIKE. Perhaps, I had the wrong syntax. Any suggestions??

      Thanks all.

        • 1. Re: ejb-ql - search function
          Daniel Hinojosa Master

          You can't use LIKE with ejb-ql. Its the law according to O'Reilly's EJB book and I am assuming that the spec agrees with that notion!

          To overcome the situation, duplicate your in the jbosscmp-jdbc.xml and replace ejb-ql with jboss-ql and you'd be finer than a girl with shaved legs.

          I modified the below for you. Also make sure that when you send the your param in, that it has your appended '%' to it.



          <query-method>
          <method-name>findByVendor</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <jboss-ql>
          <![CDATA[SELECT OBJECT(i) FROM T_Item i WHERE i.vendor.name LIKE ?1]]>
          </jboss-ql>