-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: java.util.Date and query criteria
PostPosted: Mon Nov 30, 2009 11:10 am 
Newbie

Joined: Mon Nov 30, 2009 10:42 am
Posts: 1
I have a MySQL table with a column type Date. In my hibernate mapping file I have mapped this column to java.util.Date. Now, while trying to retrieve results using criteria api 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.

I posted this question in stackoverflow.com(http://stackoverflow.com/questions/1819 ... l-and-date) and got a solution in which I was asked to map the column to java.sql.Date and it works. But, I am curious as to why it does not work with java.util.Date even while querying since the column is of type Date and not Datetime?

If I change the mapping to java.sql.Date is there something I should keep in mind since this piece has been running in production for the past 2 years.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.