The table has a timestamp. The approximate value in this may be 2010-03-30 13:42:42. With Hibernate, I am performing a limited range query. Between them ("column name", fromDate, toDate).
The Hibernate mapping for this column is as follows.
<property name="orderTimestamp" column="order_timestamp" type="java.util.Date" />
Let's say I want to find out all the entries that have a date of March 30, 2010 and March 31, 2010. The range request in this field is performed as follows.
Date fromDate = new SimpleDateFormat("yyyy-MM-dd").parse("2010-03-30"); Date toDate = new SimpleDateFormat("yyyy-MM-dd").parse("2008-03-31"); Expression.between("orderTimestamp", fromDate, toDate);
This does not work.
The request is converted to the corresponding timestamps as "2010-03-30 00:00:00" and "2010-03-31 00:00:00". Thus, all entries for March 31, 2010 are ignored.
A simple solution to this problem might be to have the end date be "2010-03-31 23:59:59". But I would like to know if there is a way to match only the date part of the timestamp column.
Also, does Expression.between() include both restrictions? The documentation does not shed light on this.
java date postgresql orm hibernate
Shashikant Kore
source share