3 Replies Latest reply on Jul 3, 2005 2:23 AM by stoneinwind

    EJB-QL WHERE ... LIKE construct problem

    atonyd

      Using JBoss 3.2.3, I'm trying to implement a finder method on an entity using a wildcard and the WHERE ... LIKE construct.

      My EJB-QL is as follows.

      SELECT OBJECT(o) FROM BicBankEntity AS o
      WHERE o.cInstCouLoc like ?1

      This fails with the following error when installing the EJB.

      [ObjectName: jboss.j2ee:jndiName=IntraInstitutionVolumeEntityRemote,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL
      statement 'SELECT OBJECT(o) FROM BicBankEntity AS o WHERE o.cInstCouLoc like ?1
      '; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encounte
      red "1" at line 1, column 67.
      Was expecting:
      <STRING_LITERAL> ...
      )]

      I have tried using the following EJB-QL

      SELECT OBJECT(o) FROM BicBankEntity AS o
      WHERE o.cInstCouLoc like '?1%'

      but the SQL generated merely tries to match the column with the literal '?1%'.

      How should the WHERE ... LIKE clause be specified?, is this a bug in 3.2.3.

      Any help would be appreciated.

      Thanks in advance

        • 1. Re: EJB-QL WHERE ... LIKE construct problem
          yangqing19

          I have encountered the same problem with you.But when i deployed it in Jboss4.0,it works.I dont konw why,do you?

          • 2. Re: EJB-QL WHERE ... LIKE construct problem
            lafr

            With JBoss 3.2.x implementing EJB 2.0 the like operator with a varaiable as argument is not supported for standard apps. Constant values are supported. If you surround the placeholder with '' this is a constant string, not a variable any more.
            There is an jboss specific extension which supports this.
            Put a constant after like in ejb-jar.xml and put the same query in jbosscmp-jdbc.xml with a variable. As far as I remember, the % sign has to be in the variables content.

            With JBoss 4.0 implementing EJB 2.1 the like operator with a variable is supported as a standard feature.

            • 3. Re: EJB-QL WHERE ... LIKE construct problem
              stoneinwind

              Hi, all
              This problem troubles me for several days. Now I know it is a ?????Limitation, thank you guys very much!