Very recently I came across a situation where in the Date that
was being persisted into the database was saving the Date correctly but the Time
was being saved as “00:00:00”.
·
Hibernate – Annotated
·
Oracle 11g
The issue was resolved by changing the value of the TemporalType
Enum in the @Temporal annotation carried by the getter of the respective
attribute in the domain object from TemporalType.DATE to TemporalType.TIMESTAMP.
The annotation @Temporal must be specified for persistent
fields of type java.util.Date and java.util.Calendar. It may be used only for fields
of these types. This annotation can be used in conjunction with the other basic
annotations like Id.
Javadocs for @Temporal: http://docs.oracle.com/javaee/6/api/javax/persistence/Temporal.html
Javadocs for the Enum: http://docs.oracle.com/javaee/5/api/javax/persistence/TemporalType.html
No comments:
Post a Comment