I have timestamp in database and in application i do have date . I like to write hibernate criteria in the way that hibernate can pull all entries those matches with date, not time part.
e.g.
in DB timestamp
2011-12-01 15:14:14
and in application i do have java.util.Date which has by default time part.
my problem is when i search entries from database with following code i get nothing
DetachedCriteria criteria = DetachedCriteria.forClass(MyClass.class);
criteria.add(Restrictions.like(TIMESTAMP_FIELD, javaUtilDate));
List entries =this.getHibernateTemplate().findByCriteria(criteria);
thanks in advance
If you are looking for a general use of filtering by date range (eg. from today until tomorrow).
I use it that way:
YourService.java
YourDAO.java
DateHelper.java
And of course – there is always space for refactoring in every code.