4 Replies Latest reply on Jan 16, 2003 11:34 AM by markuspr

    EJB-QL: LOCATE problem

    markuspr

      Hi,

      because of the LIKE problem in EJB-QL I've used the following finder code for my CMP2.0 bean (using Xdoclet):

      * @ejb:finder signature="java.util.Collection findByTitleFrag( java.lang.String pTitle )"
      * query="SELECT OBJECT(o) FROM Item AS o WHERE LOCATE(o.title, ?1) >= 0"
      *
      * @jboss:finder-query name="findByTitleFrag"
      * query="UPPER(I_TITLE) LIKE UPPER('%{0}%')"

      But this doesn't work! It always returns every bean! If I use '> 0' instead of '>= 0' it doesn't return any bean, but there exist some....

      Thanks for your help,
      Markus

        • 1. Re: EJB-QL: LOCATE problem
          pranav

          Hi Markus,

          The @jboss:finder-query will override the query part of @ejb:finder.

          Cheers

          • 2. Re: EJB-QL: LOCATE problem
            markuspr

            Hi Pranav,

            I've deleted the @jboss:finder-query, and I've changed this query, too. But all this doesn't change the results.
            Without @jboss:finder-query it doesn't also work. It always returns every bean.
            By the way: My @jboss:finder-query has to find the same beans as the @ejb:finder query. The queries are equivalent...

            Greetings,
            Markus

            • 3. Re: EJB-QL: LOCATE problem
              pranav

              Dear Markus,

              The fragment value you are providing in the method may be maching the start of all the Titles, the locate method returns the index of the first match.

              Send me the test data that you have in database...which database are you using..??

              Pranav

              • 4. Re: EJB-QL: LOCATE problem
                markuspr

                Dear Pranav,

                here are some test titles out of my MySQL 4.0.5max DB:
                - A new book
                - Another new book
                - Something about computer science
                - What a day
                - Jboss hates me
                - It still hates me

                If I'm searching for 'book' then it get every book bean, if I'm using '>=' and no book bean if I use '>'...

                Markus