The JDBC temporal classes correspond to SQL DATE, TIME, and TIMESTAMP: java.sql.Date, java.sql.Time, and java.sql.Timestamp. They are also subclasses of java.util.Date. section 6.3.1
A java.util.Date property can come back from Hibernate as any of these JDBC subclasses, depending on its TemporalType mapping. In particular, Timestamp can retain database nanoseconds that java.util.Date cannot represent, making equals() comparisons unreliable across the two types. Prefer java.time classes for new domain-model properties; JPA 2.2 supports them. section 6.3.1
Comparing loaded values
If nanoseconds do not matter, compare getTime() values rather than calling equals() on mixed java.util.Date and JDBC temporal values. Avoid mixing those values in a HashSet, which uses equals(). section 6.3.1
Table 6.3 Date and time types (view table figure)
Compare the JDBC classes’ SQL mappings with Calendar and java.time alternatives. section 6.3.1
