1 Reply Latest reply on Nov 25, 2002 12:20 PM by jboynes

    EJB-QL Parse Exception in 3.0.4

    viktor

      Guys,

      I have a strange problem trying to use the following EJB-QL query:

      SELECT OBJECT(o) FROM StatusHistory AS o WHERE o.msgId=?1

      Is there anything wrong with it ?

      Exception is thrown:

      org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.msgId" at line 1, column 50.
      Was expecting one of:
      "NOT" ...
      "(" ...
      <COLLECTION_VALUED_PATH> ...
      <STRING_VALUED_PATH> ...
      "CONCAT" ...
      "SUBSTRING" ...
      <BOOLEAN_VALUED_PATH> ...
      <DATETIME_VALUED_PATH> ...
      <ENTITY_VALUED_PATH> ...
      <IDENTIFICATION_VARIABLE> ...
      <NUMERIC_VALUED_PATH> ...
      "LENGTH" ...
      "LOCATE" ...
      "ABS" ...
      "SQRT" ...
      "+" ...
      "-" ...
      <INTEGER_LITERAL> ...
      <FLOATING_POINT_LITERAL> ...
      <NUMERIC_VALUED_PARAMETER> ...
      )
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)



      The following is an extract from ejb-jar.xml


      <display-name>StatusHistory</display-name>
      <ejb-name>StatusHistory</ejb-name>
      <local-home>foo.messagestore.ejb.StatusHistoryHome</local-home>
      foo.messagestore.ejb.StatusHistory
      <ejb-class>foo.messagestore.ejb.StatusHistoryBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.math.BigDecimal</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>StatusHistory</abstract-schema-name>
      <cmp-field>
      <field-name>statusHistoryId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>msgId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>histTimestamp</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>status</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>comments</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>source</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>sourceChangeRef</field-name>
      </cmp-field>
      <primkey-field>statusHistoryId</primkey-field>

      <query-method>
      <method-name>findByMsgId</method-name>
      <method-params>
      <method-param>java.math.BigDecimal</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(o) FROM StatusHistory AS o WHERE o.msgId=?1</ejb-ql>


        • 1. Re: EJB-QL Parse Exception in 3.0.4
          jboynes

          JBoss does not recognize BigDecimal as a defined EJB-QL type and so treats it as a ValueClassValuedPath. These cannot be used in ComparisonExpression's.

          Fixed decimals like BigDecimal are specifically not supported by the spec (11.2.12) so unless you can convert your id's to an integer type EJB-QL may not work for you.

          You might be able to code this with declared-sql.