If you have a column of type Date in your table, in your hibernate mapping, map it to type java.sql.Date. We had such a field and we mapped it to java.util.Date. The problem with this mapping is, while querying, in your hibernate query criteria you have to normalize the time fields(i.e set hours, minutes and seconds to zero) to get results. In my opinion Hibernate should work with java.util.Date when the column is of type Date. But it does not.

For those of you who do not know about java.sql.Date, it is a sub class of java.util.Date with all the time fields set to zero.

Advertisements