2 Replies Latest reply on Jul 17, 2003 6:44 PM by humx_hn

    Exception when Query EjbEntity with Between Date1 And Date2

    humx_hn Newbie

      Hi, All.

      I am puzzled when I wan to execute a ejb query with two java.sql.Date objects as parameter. The jboss server give following exception:

      ===================
      [ObjectName: jboss.j2ee:jndiName=WorkLocalHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL
      statement 'SELECT OBJECT(w) FROM T_work w
      WHERE w.principalId = ?1 AND w.f
      inishFlag = false
      AND w.finishTime BETWEEN ?2 AND
      ?3'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encoun
      tered "BETWEEN" at line 3, column 66.
      Was expecting one of:
      "=" ...
      "<>" ...
      )]

      ===================

      myEjb query is wtote as following:

      ===================
      <!-- query by principal and time interval -->

      <query-method>
      <method-name>findByTimeInterval</method-name>
      <method-params>
      <method-param>java.lang.Integer</method-param>
      <method-param>java.sql.Date</method-param>
      <method-param>java.sql.Date</method-param>
      </method-params>
      </query-method>
      <!--
      If the relationship of the Entity beans is java.util.Collection,
      you must use IN syntax.For example, order to order Items.
      -->
      <ejb-ql>
      <![CDATA[
      SELECT OBJECT(w) FROM T_work w
      WHERE w.principalId = ?1 AND w.finishFlag = false
      AND w.finishTime BETWEEN ?2 AND ?3
      ]]>
      </ejb-ql>


      ===================


      how can I do? Thank.