Hi;
how can i tell hibernate to map a default value to a field instead of a null value ?
For example i have a "lastUpdate" field and i would like hibernate to set it to the postgresql function now() .
I found a way to do this for a creationDate column which take only a default value at the first insert with:
Code:
@Column(name = "`creationDate`", insertable = false, updatable = false, columnDefinition = " timestamp default now()")
public Date getCreationDate() {
return creationDate;
}
Now i would like the same think for:
Code:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "`updateDate`")
public Date getUpdateDate() {
return updateDate;
}
So i need updateDate to be updatable and with now() instead of null for the default value when my property is null.
It would save me some programming time as I need to implement this in many classes.