title: How to insert data with automatic value to createdDate and updatedDate using Spring, Hibernate?
body: <p>I want to insert data with automatic insertion of created_at date time and respective updated_at date time.</p>
  
  <p>I have a pojo as:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Basic(optional = false)
  @Column(name = "id")
  private Integer id;
  
  @Basic(optional = false)
  @Column(name = "name")
  private String name;
  
  @Basic(optional = false)
  @CreationTimestamp
  @Column(name = "created_at")
  @Temporal(TemporalType.TIMESTAMP)
  private Date createdAt;
  
  @UpdateTimestamp
  @Column(name = "updated_at")
  @Temporal(TemporalType.TIMESTAMP)
  private Date updatedAt;
  </code></pre>
  
  <p>And in my database, I have used DATETIME as a type for created_at and updated_at. But I am not being able to insert data rather it gives an error message <strong>not-null property references a null or transient value: com.project.test.entity.Stamp.createdAt.</strong></p>
  
  <p>I want to know the proper way to define my database schema for created_at and updated_at DateTime field to make it generate automatically.</p>