1 Reply Latest reply on May 12, 2003 2:59 AM by Dietmar Scheidl

    EJB-QL 'Like' Query

    klogg Newbie

      Hi,

      I am trying create a finder method in my EJB that will find all entities whose names start with a particular letter, but alas the query I have doesn't return anything (I am running JBoss with MySQL).

      My query is:

      select object(a)
      from Artist a
      where a.name like '?1%'

      Any help would be appreciated!

      Thanks,
      Jeff.

        • 1. Re: EJB-QL 'Like' Query
          Dietmar Scheidl Newbie

          Hi,

          EJB-QL does not support LIKE ?1 instead you have to use JBossQL.

          Therefore you have to put the definition of the finder into your jbosscmp-jdbc.xml file.

          e.g.:


          <ejb-name>YourBean</ejb-name>
          ...

          <query-method>
          <method-name>findByMatch</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <jboss-ql><![CDATA[
          SELECT OBJECT(u)
          FROM YourBean u
          WHERE u.yourField LIKE ?1
          ]]></jboss-ql>