I am trying to perform an HQL query on a joda date time field in a table and its not giving any results.
The date is stored in MySQL database as 2013-06-13 05:00:00 However in my method below, after the dateTime.toDate() is called, its going to the db as Thu Jun 13 00:00:00 CDT 2013. If I don't do the .date conversion, the method complains that a date is required.
Products is my table name
impactTime is my pojo field and table column name
Also tried
query.setTimestamp("impactTime", dateTime.toDate()); but that did not work either.
Please advice.
I am calling the method below -
Code:
public List<String> getAllIds(final DateTime dateTime) {
Query query =
getSession().createQuery(
"select id from Products where impactTime = :impactTime");
query.setDate("impactTime", dateTime.toDate());
return query.list();
}