Showing results for 
Search instead for 
Did you mean: 

ejb-ql with java.sql.Date or java.util.Date ?

Former Member
0 Kudos

I need to query the cmp entity bean over a RANGE OF DATE. Currently, the column type "DATE" (java.sql.Date) doesnt allow me to do the query, error returned during ejb-ql statement validation (first param. and second param. are both java type java.sql.Date):

select object(b) from MyEntity b where b.MYDATE > ?1 and b.MYDATE > ?2

select object(b) from MyEntity b where b.MYDATE between ?1 and ?2

i also saw

"If a cmp-field represents a date type and will be involved in a QL query, its Java type must be java.util.Date.”

Does it meant in order to query over a range of date, the table column type has to be "TIMESTAMP" and use java type java.util.Date? Or, is there any other option to get what i want?

Any help would be much appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

create additional column of type LONG to represent date.

dateFormat is of type java.util.Date:

long newLongDate = dateFormat.getTime();

select object(b) from MyEntity b where b.MYLONGDATE > ?1 and b.MYLOGDATE <= ?2