Basically, I am trying to map a table like below,
created_on datetime not null default current_timestamp,
modified_on timestamp not null default current_timestamp,
Here is my code,
@Column(name="modified_on", updatable=false, insertable=false, columnDefinition="timestamp not null default current_timestamp")
@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.ALWAYS)
private Date modifiedOn;
@Column(name="created_on", updatable=false, insertable=false, columnDefinition="datetime not null default current_timestamp")
@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.INSERT)
private Date createdOn;
I want these two column would be updated automatically,
during insert, created_on would have current_timestamp
during every update, created_on would left unmodifed by modified_on will be updated.
I am new to hibernate, how can I accomplish this.
Thanks,
|