I have an object with a Date field. The hibernate maps this object to a java.util.Date. My object also has a compareTo function, which sorts itself by date.
When the compareTo function is called, there is an error: java.lang.ClassCastException: java.util.Date at java.sql.Timestamp.compareTo
because Hibernate passed in a java.sql.Timestamp.
The compiler allows this because Timestamp extends Date - HOWEVER - the documentation explains this is implementation inheritance not type enheritance, and so code should not view Timestamp values generically as an instance of java.util.Date.
If I specify java.util.Date in my hibernate mapping file, I should not receive a java.sql.Timestamp.
|