HQL(hibernate) timestamp range match

Posted by Saky on Stack Overflow See other posts from Stack Overflow or by Saky
Published on 2010-05-19T11:10:46Z Indexed on 2010/05/19 11:20 UTC
Read the original article Hit count: 391

Filed under:
|
|
|

I need to write a query to get an object between a range of time, currently the query looks like this:

Timestamp from = ... 
Timestamp to = ...

getHibernateTemplate().find("from " + Person.class.getName() + " ml where ml.lastModifiedOn>="+from.toString()+" and m1.lastModifiedOn<=" + to.toString());

However, this doesnot work for obvious reasons. How can I format the timestamp to be acceptable by the query.

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 16 near line 1, column 123 [from Person ml where ml.lastModifiedOn>=2010-02-12 16:00:21.292 and m1.lastModifiedOn

© Stack Overflow or respective owner

Related posts about hql

Related posts about timestamp