Is it possible to have hibernate generate the value of a column when insterting the row the first time?
I know it is possible for the ids with @Id and @GeneratedValue and @SequenceGenerator yet I was not able to have an entity that has a column which has the default value of NOW().
For example:
Code:
@Entity
@Table(name = "users")
@SequenceGenerator(name = "users_seq", sequenceName = "users_seq")
class User {
@Id
@GeneratedValue(generator = "users_seq")
private long id;
@Temporal(TemporalType.TIMESTAMP)
private Date created;
private String username;
}
Now I would like that created is set to NOW() when the record is inserted. Is that possible? And how?