0

I am using an external database and I can't use database-specific functions in my query.

startdate is saved as a bigint and is a UNIX timestamp (milliseconds since the epoch).

So in my query I ignore milliseconds.

WHERE ma.conversation.room IS NULL AND (ma.conversation.startdate >= :startDate AND ma.conversation.startdate <= :endDate)

and my method sets the parameters thus

.setParameter("startDate", startDate.getTime())
.setParameter("endDate", endDate.getTime())

I know that this is very bad idea but I cannot change the database.

I do not know why i have got strange result in my tests ? for example this is my parameter for NamedQuery:

QUERY StartDate :134 904 315 5000, endDate: 134 904 902 2000

and i print out my list result and i have got:

query result : startdate=2013-10-01 01:50:23, startdate time=138 058 502 3863 ......

Why that query brings me this results ??

  1. though 138 058 502 3863 >= 134 904 315 5000 (true)
  2. but 138 058 502 3863 =< 134 904 902 2000 (not true !)

Question

Is it a good idea to use the >= and =< operators?

4

0 回答 0