Reputation: 66761
I have a table with a timestamp field in it entrydate
(Postgres timestamp without timezone
type), however when it is propagated with hibernate, all of its values seem to be truncated, granularity wise, to just midnight of the current day (well, of the Date set) a la 2013-04-19 00:00:00
how do I get better granularity like seconds, hours, minutes, milliseconds?
hibernate cfg xml file:
<class name="Tape" table="Tape">
<property column="EntryDate" name="EntryDate" type="date"/>`
...
</class>
It uses a java.util.Date
object within the java class Tape
, with appropriate getters and setters, and they do work for serializing it, it just ends up saving it in the DB without any precision/granularity more than the day itself.
Upvotes: 0
Views: 237
Reputation: 66761
Turns out that "date" in hibernate is "just the day, not the hour" unlike a java Date class, which has millisecond granularity.
Fix was to use hibernate timestamp instead:
<property column="EntryDate" name="EntryDate" type="timestamp"/>
now it has millisecond granularity in the DB.
Upvotes: 1