Thank you brenuart, but I still miss the point.
Why does TimestampType.getReturnedClass() return a java.util.Date instead of a java.sql.Timestamp?
Ask Gavin ;-)
To be correct, Hibernate DOES return a java.sql.Timestamp but casted to a java.util.Date...
Although java.sql.Timestamp is assign-compatible with a java.util.Date - it is not exactly the same, in the sense that Timestamp.equals(Date) will not work... Quite annoying :-(
Here is what you should do - beside asking to change Hibernate ;-) - is to create a UserType for what you need:
- either your own TimestampUserType
that would return a Timestamp - if this is what you need;
- either your own DateTimeUserType
that would convert the java.sql.Timestamp into a concrete java.util.Date (if you need Date+Time precision returned as a java.util.Date).
You are not the first having this problem - although the Jira issue mentionned in the URL shown above is closed - maybe you could still vote for it ;-)
I had to write such DateTimeUserType for our project - I can post it here if needed.