3 Replies Latest reply on Apr 24, 2003 12:59 PM by Brett Connor

    jboss-3.2.0 : Problem with EJBQL

    kvikram Newbie

      Hi
      I'm using jboss-3.2.0_tomcat-4.1.24.I am trying to deploy an CMP entity bean (EJB2.0 ).The deployment succeeds initailly but later throws a DeploymentException i.e.

      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT OBJECT(u) FROM Users AS u WHERE u.USERTYPE = ?1'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.UnknownPathException: Unknown terminal field: at line 1, column 49. Encountered: "USERTYPE" after: "u.")]

      The portion of ejb-jar.xml causing the exception is


      <query-method>
      <method-name>findByUsertype</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      <![CDATA[SELECT OBJECT(u) FROM Users AS u WHERE u.USERTYPE = ?1]]>
      </ejb-ql>


      Which looks pretty much ok to me.
      Any pointers why it's throwing this exception??

      Thanx in advance
      Vikram. K

        • 1. Re: jboss-3.2.0 : Problem with EJBQL
          Pablo Delgado Newbie

          I think your query should be ...

          <ejb-ql>
          [CDATA[SELECT OBJECT(u) FROM Users u WHERE u.usertype = ?1]]
          </ejb-ql>

          with u.usetype in lowercase letters (because I suppose usertype is the field name and is in lowercases)

          Due ?1 is a java.lang.String I don't know if you need to put ?1 between '?1'

          If putting usertype in lowercase does not work try the latter.

          Let me know if if helped you.

          Good luck.

          Pablo

          • 2. Re: jboss-3.2.0 : Problem with EJBQL
            kvikram Newbie

            Hi Pablo
            My column name is UserType.
            But Changing from u.USERTYPE to u.usertype solved the problem.
            I never doubted it cause "sql statements are supposed to be non case sensitive".

            Tried the 2nd option too. It didn't throw any exceptions But didn't fetch any results. Maybe because it isn't a well formed
            "java.sql.PreparedStatement".

            Thanx a lot
            Vikram

            • 3. Re: jboss-3.2.0 : Problem with EJBQL
              Brett Connor Newbie

              The terminal name refers to the name as per the abstract getter / setter convensions, ie remove the [gs]et. While SQL is not case sensitive, EJB-QL is not SQL, and is case sensitive in some parts. You will find the same on schema name also I think.

              Re the = ?1 vs '?1', the second form will return no rows because it will be looking for rows where the usertype column has the literal value "?1", ie it's treating it as a literal rather than a variable.