4 Replies Latest reply on Apr 24, 2003 3:50 PM by lafr

    EJB-QL and LIKE operator

    abrasax

      Hi,

      I try to use JBoss 3.0.0 alpha with CMP2.0. It looks fine, but I have a little problem with LIKE operator. It works well when I use static string for comparison, but when I want to use parameter, then it doesn't work.

      SELECT OBJECT(t) FROM InfoText t WHERE t.text LIKE '?1'
      -- this query doesn't replace the parameter symbol with actual value

      SELECT OBJECT(t) FROM InfoText t WHERE t.text LIKE ?1
      -- this query doesn't recognise the WHERE clause at all and performs SELECT OBJECT(t) FROM InfoText t

      Is there something wrong with my EJB-QL queries? Or is it a bug?

      Thanx
      Martin

        • 1. Re: EJB-QL and LIKE operator
          pazu

          The EJB-QL specification doesn't allow parameters in LIKE operators. Yes, that's pretty much useless. Some vendors offer extensions that permit this.

          MVCSoft Persistence Manager (www.mvcsoft.com) is one of them. It allows the ... LIKE ?1 syntax.

          • 2. Re: EJB-QL and LIKE operator
            abrasax

            Thank you for info.

            I used LOCATE function instead. Anyway, it's a pitty and shame EJB QL doesn't support this...

            Martin

            • 3. Re: EJB-QL and LIKE operator
              ucftcys

              Hi, Could you explain how to use LOCATE in this situation??

              • 4. Re: EJB-QL and LIKE operator
                lafr

                It's also possible with jboss-ql.
                From my address bean a search by matchcode with like (XDoclet tags):

                * @ejb.finder signature="java.util.Collection findByMatchcode( java.lang.String matchcode )"
                * view-type="local"
                * query="SELECT OBJECT(o) FROM Address AS o WHERE o.matchcode LIKE '%SIEMENS%'"
                * result-type-mapping="Local"
                * @jboss.query signature="java.util.Collection findByMatchcode( java.lang.String matchcode )"
                * query="SELECT OBJECT(o) FROM Address AS o WHERE o.matchcode LIKE ?1 ORDER BY o.addressId"