epbernard wrote:
use equals, not ==
beware the precision, some java.util.date can be more precise than the one you get from DB.
There is something more to care about: by default, Hibernate will map java.util.Date instances to a JDBC java.sql.Timestamp (unless you specify a type
date or
time - not
timestamp in your mapping file).
When reading your data back, your original date properties will be initialized with
java.sql.Timestamp rather than
java.util.Date... This may cause problems later in your code if you try to compare these fields with other
java.util.Date - see
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Timestamp.html
To avoid problems, we used to implement a special UserType that converts timestamps back to util.dates.