3 Replies Latest reply on Mar 12, 2003 11:47 AM by Dan Osterrath

    EJB QL fails

    Dan Osterrath Newbie

      Hi,

      I'm using JBoss 3.0.6 and PostgreSQL with ant and XDoclet for generating the {j|w}ar's.
      When I write the following in a EntityClass:

      * @ejb:finder
      * signature="ejb.gp.interfaces.EntityUser findByNameSurname(java.lang.String pName, java.lang.String pSurname)"
      * @jboss:finder-query
      * name="findByNameSurname"
      * query="name = {0] and surname = {1}"

      Jboss warn's about not giving him a query, as required in CMP 2.0. Probably because in the ejb-jar.xml file no query is mentioned. ;-)
      So I tried to give him a query with:

      * @ejb:finder
      * signature="ejb.gp.interfaces.EntityUser findByNameSurname(java.lang.String pName, java.lang.String pSurname)"
      * query="SELECT Object(user) FROM my_user user WHERE name=?1 AND surname=?2"

      XDoclet creates the following query tag in ejb-jar.xml:


      <query-method>
      <method-name>findByNameSurname</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT Object(user) FROM my_user user WHERE name=?1 AND surname=?2]]></ejb-ql>


      But JBoss doesn't like this. When deploying it, the log file contains:

      2003-03-06 16:45:40,964 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/gp/EntityUser,service=EJB
      org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "my_user" at line 1, column 26.
      Was expecting one of:
      "IN" ...
      <ABSTRACT_SCHEMA> ...
      )
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:44)
      ... and so on ...

      So where is the problem?