1
votes

I have a field of time Timestamp in my MySQL database which is mapped to a date datatype in my Bean.
Now I want a query by which I can fetch all records in the database for which the difference between the current timestamp and the one stored in the database is > 20 minutes.

How can I do it?

What I want is

select T from MyTab T where T.runTime - currentTime > 20 minutes

I tried the following

Query  query =  getSession().createQuery("Select :nw - T.runTime   from MyTab T");
  query.setDate("nw", new Date());

It returns some values like -2.0110930179433E13 .

How can I model this in SQL/Hibernate? Even if I get some native SQL query (MySQL) then it's ok.

1
see TIMEDIFFdiEcho

1 Answers

1
votes