0 Replies Latest reply on Dec 30, 2004 10:49 AM by James Zhang

    Deployment Exception when using EJB-QL with JBoss 4.0

    James Zhang Newbie

      I was trying to follow the CMP example code from book "Teach yourself EJB in 21 days", but my JBoss server always give me the following deploy error:

      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT OBJECT(o) FROM Order AS o
      WHERE o.status = ?1'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "Order" at line 1, column 23.
      Was expecting one of:
      "IN" ...
      <ABSTRACT_SCHEMA> ...
      )
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:52)
      ...

      I checked the configuration files and am quite sure that the schema name is correct. Here is related potion of my ejb-jar.xml file:

      ...

      <ejb-name>OrderEJB</ejb-name>
      day11.OrderHome
      day11.Order
      <ejb-class>day11.OrderEJB</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Order</abstract-schema-name>
      <cmp-field>
      <field-name>orderId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>studentId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>orderDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>status</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>amount</field-name>
      </cmp-field>
      <primkey-field>orderId</primkey-field>

      <query-method>
      <method-name>findByStatus</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      [CDATA[SELECT OBJECT(o) FROM Order AS o
      WHERE o.status = ?1]]
      </ejb-ql>


      <query-method>
      <method-name>ejbSelectAllOrderAmounts</method-name>
      <method-params>
      </method-params>
      </query-method>
      <ejb-ql>
      [CDATA[SELECT o.amount FROM Order AS o
      WHERE o.orderId IS NOT NULL]]
      </ejb-ql>


      ...

      And the jbosscmp-jdbc.xml:

      ...

      java:/DefaultDS
      <datasource-mapping>mySQL</datasource-mapping>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <pk-constraint>true</pk-constraint>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

      ...

      Anybody has similar problem before? Any suggestion would be greatly appreciated!

      Thanks!