I have a MySQL table with one of the column type 开发者_StackOverflow社区as Date. In my hibernate mapping file I have mapped this column to type java.util.Date. Now in HQL while trying to retrieve objects based on date equality I do not get any results if I set the Date using new Date(). If I normalize the date by setting hours, minutes and seconds to zero I get results. Is this required since I have declared the SQL column type to be a Date and not Timestamp?
Try java.sql.Date
Hopefully this will help you out with the date equality issue.
RDJ
I was able to use java.util.Date with a SQL Server Date column by explicitly setting the @Type:
@Type(type="date")
public java.util.Date getDate() {
return date;
}
Without the annotation, I was getting
java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
with Hibernate 3.5.1-final
精彩评论