title: Creation date is set as null by hibernate, when changes are made during persist operation
body: <p>I am creating a course object and persisting in H2 database using hibernate and setting the creation date using @CreationTimestamp annotation</p>
  <pre><code>    @Entity
  @Table(name = &quot;COURSE_DETAILS&quot;)
  public class Course {
  
      @Id
      @GeneratedValue
      private Long id;
  
      @Column(name=&quot;NAME&quot;, nullable = false)
      private String name;
  
      @UpdateTimestamp
      private LocalDateTime lastUpdatedDate;
  
      @CreationTimestamp
      private LocalDateTime createdDate;
  // constructors and getter and setters
  }
  
  </code></pre>
  <pre><code>@Repository
  @Transactional
  public class CourseRepository {
  
   @Autowired
      private EntityManager entityManager;
  
  public void play(){
       Course course = new Course(&quot;New Course&quot;);
          entityManager.persist(course);
          course.setName(&quot;Not null&quot;);
  }
  }
  </code></pre>
  <p>I am getting following entry in the database
  <br></p>
  <p>ID      CREATED_DATE    LAST_UPDATED_DATE               NAME<br />
  <br>
  1       null            2021-10-06 22:31:43.465         Not null</p>
  <p>but when i change the code to</p>
  <pre><code>Course course = new Course(&quot;New Course&quot;);
          entityManager.persist(course);
          course.setName(&quot;Not null&quot;);
          entityManager.flush();
  </code></pre>
  <p>I am getting following entry in db
  <br>
  ID      CREATED_DATE              LAST_UPDATED_DATE         NAME
  <br>
  1       2021-10-06 22:38:37.941   2021-10-06 22:38:37.963   Not null</p>
  <p>Why the creation date is set to null in first case.</p>