My entity class:
@Entity
@Table(name = \"user\")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
You can just create a new Date() whenever your instance is created, and then update the updated field whenever the entity gets updated:
private Date created = new Date();
private Date updated = new Date();
@PreUpdate
public void setLastUpdate() { this.updated = new Date(); }
Don't provide a setter for any of these methods, only getters.