Rather than Hibernate providing a copy of the datetime for the timestamp, I'd like to be able to specify that the database getdate() or equivalent function to be used for the insert/update.
Having surveyed the forums & literature for this, there doesn't appear to be a neat way of doing this. One would have to use an annotation as follows:
@Temporal(TemporalType.TIMESTAMP)
@Column(name="InputTime", insertable=false, updatable = false)
@Generated(GenerationTime.ALWAYS)
private Date inputTime;
and then write an update trigger for the column. However this doesn't satisfy the case where you don't want the timestamp field updated every time the row is updated.
It would be nice to have an annotation such as
@Temporal(TemporalType.TIMESTAMP, source="database")
@Generated(GenerationTime.ALWAYS)
@Column(name="InputTime", insertable=false, updatable = false)
private Date inputTime;
Are there any plans to introduce such a feature?
|