EJB-QL date comparison
843829May 15 2002 — edited May 21 2002I was trying to use EJB-QL (with Sun's J2EE reference implementation) to implement a CMP bean method
findQuotes( String symbol, Date start, Date end )
to find items with a given symbol and in a given date range, but I can't find any EJB-QL examples with dates; seems the comparisons are for numeric, not date, values. I've I tried
SELECT OBJECT(a) FROM StockQuoteSchema AS a WHERE a.symbol = ?1 AND a.theDate
BETWEEN ?2 AND ?3
and also
SELECT OBJECT(a) FROM StockQuoteSchema AS a WHERE a.symbol = ?1
AND a.theDate >= ?2 AND a.theDate <= ?3
. The a.symbol = ?1 part is OK, but the EJB-QL compiler says essentialy "Error, invalid type for
the (a.theDate >= ?2) portion".
(The Cloudscape-- the DBMS for the J2EE reference implementation-- SQL syntax page gives "myDate BETWEEN DATE'2002-10-12' AND DATE'2002-12-11'" as a valid query, but EJB-QL variations thereof don't work either...)
If you happen to know a solution, or where to look to find one, I'd appreciate it!
Thanks,
~Chris