HQL(hibernate) timestamp gamme de match

J'ai besoin d'écrire une requête pour obtenir un objet entre une plage de temps, actuellement la requête ressemble à ceci:

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

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

Cependant, ce n'est pas travailler pour des raisons évidentes. Comment puis-je format de l'horodatage pour être acceptable par la requête.

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 16 près de la ligne 1, colonne 123 [de Personne ml où ml.lastModifiedOn>=2010-02-12 16:00:21.292 et m1.lastModifiedOn

  • essayez aaaa-MM-jj HH:MM:SS
  • ne fonctionne pas. .
InformationsquelleAutor Saky | 2010-05-19