The reason you are not getting a where clause is because your where clause
is invalid.  The engine does not throw an exceptions when it can't parse a
statement (this is a bug).  EJB-QL does not allow the '>=' operator for
datetime types. The BNF follows:

comparison_expression ::=
      string_value { =|<>} string_expression |
      boolean_value { =|<>} boolean_expression} |
      datetime_value { = | <> | > | < } datetime_expression |
      entity_bean_value { = | <> } entity_bean_expression |
      arithmetic_value comparison_operator single_value_designator

As for the statement "Date and time values should use standard Java long
milliseconds value," this didn't make much sense to me.  I use the JBoss
JDBC type mapping to set the parameters, so it should work.

-dain

> -----Original Message-----
> From: Peter Levart [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 14, 2002 11:59 AM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-dev] EJB QL parser bug?
> 
> 
> The following is writen to the server.log for one of my CMP 
> 2.0 finder 
> methods (CVS jboss3.0alpha) during deployment:
> 
> 2002-01-14 17:46:40,443 DEBUG 
> [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.ContactBean.fin
> dInDatetimeRange] 
> EQL-QL: SELECT DISTINCT OBJECT(c) FROM Contact AS c WHERE 
> c.datetime >= ?1 
> AND c.datetime < ?2
> 2002-01-14 17:46:41,098 DEBUG 
> [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.ContactBean.fin
> dInDatetimeRange] 
> SQL: SELECT DISTINCT t1_c.id FROM ContactBean t1_c
> 
> 
> ...Where is the "WHERE" caluse in the SQL? Can this be a bug 
> or am I missing 
> something?
> 
> Does anybody know how to interpret the following EJB 2.0 
> spec. statement 
> (11.2.11 Restrictions):
> 
> "Date and time values should use standard Java long 
> milliseconds value."
> 
> This is "very" precise, I must say. X values should use Y 
> value, hm....
> 
> Does this mean that parameters to findXXX methods should be 
> "long" type when 
> used in date and time comparisons in EJB QL? What type of 
> parameters does 
> JBossCMP expect (accept) when used in such comparisons?
> 
> I tried the following:
> 
>          <query>
>             <query-method>
>                <method-name>findInDatetimeRange</method-name>
>                <method-params>
>                   <method-param>long</method-param>
>                   <method-param>long</method-param>
>                </method-params>
>             </query-method>
> 
>             <result-type-mapping>Local</result-type-mapping>
> 
>             <ejb-ql>SELECT DISTINCT OBJECT(c) FROM Contact AS c WHERE 
> c.datetime &gt;= ?1 AND c.datetime &lt; ?2</ejb-ql>
>          </query>
> 
> and the following:
> 
>          <query>
>             <query-method>
>                <method-name>findInDatetimeRange</method-name>
>                <method-params>
>                   <method-param>java.util.Date</method-param>
>                   <method-param>java.util.Date</method-param>
>                </method-params>
>             </query-method>
> 
>             <result-type-mapping>Local</result-type-mapping>
> 
>             <ejb-ql>SELECT DISTINCT OBJECT(c) FROM Contact AS c WHERE 
> c.datetime &gt;= ?1 AND c.datetime &lt; ?2</ejb-ql>
>          </query>
> 
> and even the following:
> 
>         <query>
>             <query-method>
>                <method-name>findInDatetimeRange</method-name>
>                <method-params>
>                   <method-param>java.sql.Timestamp</method-param>
>                   <method-param>java.sql.Timestamp</method-param>
>                </method-params>
>             </query-method>
> 
>             <result-type-mapping>Local</result-type-mapping>
> 
>             <ejb-ql>SELECT DISTINCT OBJECT(c) FROM Contact AS c WHERE 
> c.datetime &gt;= ?1 AND c.datetime &lt; ?2</ejb-ql>
>          </query>
> 
> The "datetime" field in Contact bean is:
> 
>          <cmp-field>
>             <field-name>datetime</field-name>
>             <column-name>datetime</column-name>
>             <sql-type>DATETIME</sql-type>
>             <jdbc-type>TIMESTAMP</jdbc-type>
>          </cmp-field>
> 
> 
> Entity creation and reading of this fileld work correctly for this 
> configuration...
> 
> Regards, Peter
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
> 

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to