title: Hibernate/JPA get value of column with default value in database after merge
body: <p><strong>Case:</strong> I want to get value of field which is mapped to column with default value on database side after I merge object.</p>
  
  <p><strong>Table:</strong></p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `db`.`OBJECT` (
    `OBJECT_ID` INT NOT NULL AUTO_INCREMENT,
    `NAME` VARCHAR(64) NULL,
    `CREATED_ON` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
    `EDITED_ON` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  )
  </code></pre>
  
  <p><strong>Class:</strong></p>
  
  <pre><code>@Entity
  @Table(name="OBJECT")
  public class SomeObject {
      private int id;
      private String name;
      private Timestamp createdOn;
      private Timestamp editedOn;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      @Column(name = "NAME")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Column(name = "CREATED_ON", insertable = false, updatable = false)
      public Timestamp getCreatedOn() {
          return createdOn;
      }
  
      public void setCreatedOn(Timestamp createdOn) {
          this.createdOn = createdOn;
      }
  
      @Column(name = "EDITED_ON", insertable = false, updatable = false)
      public Timestamp getEditedOn() {
          return editedOn;
      }
  
      public void setEditedOn(Timestamp editedOn) {
          this.editedOn = editedOn;
      }
  }
  </code></pre>
  
  <p><strong>DAO:</strong></p>
  
  <pre><code>@Transactional
  public class ObjectDAO {
      @PersistenceContext
      private EntityManager entityManager;
  
      public someObject merge(someObject someObject) {
          return entityManager.merge(someObject);
      }
  }
  </code></pre>
  
  <p><strong>What I want to do:</strong></p>
  
  <pre><code>SomeObject someObject = new SomeObject();
  someObject.setName("name");
  SomeObject insertedObject = objectDAO.merge(someObject);
  System.out.println(insertedObject.getId());
  System.out.println(insertedObject.getEditedOn());
  </code></pre>
  
  <p><strong>Result:</strong>
  object is inserted into database, all default values are generated properly.</p>
  
  <p><strong>Question:</strong>
  Why second println prints null, but first println prints proper value of Id which was inserted into database?</p>