Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EJB-QL date comparison

843829May 15 2002 — edited May 21 2002
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2002
Added on May 15 2002
1 comment
195 views