title: How to pass default value of Hibernate Entity field value while saving entity
body: <p>I have <strong>@Embeddable</strong> class <strong>AuditColumn.java</strong> as below. </p>
  
  <pre><code>public class AuditColumn {
  
      @Column( name = "create_user", nullable = false )
      private String createUser = null ;
  
      @Column( name = "create_date", nullable = false , columnDefinition = "datetime default now()" )
      private Calendar createDate = null ;
  
      @Column( name = "update_user", nullable = false )
      private String updateUser = null ;
  
      @Column( name = "update_date", nullable = false, columnDefinition = "datetime default now()" )
      private Calendar updateDate = null ;
  
      public static AuditColumn getInstance( String user ) {
  
          AuditColumn auditColumn = new AuditColumn();
  
          auditColumn.setCreateUser(user);
          auditColumn.setUpdateUser(user);
  
          return auditColumn ;
      }
  }
  </code></pre>
  
  <p>And other Class <strong>A.java</strong> which uses <strong>AuditColumn.java</strong> as <strong>@Embedded</strong> as below.</p>
  
  <pre><code>public class A {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private int id = -1 ;
  
      @Column(name = "first_name")
      private String firstName    = null ;
  
      @Column( name = "last_name" )
      private String lastName     = null ;
  
      @Embedded
      AuditColumn auditColumn = null ;
  }
  </code></pre>
  
  <p>Trying to save the Entity A as below.</p>
  
  <pre><code>A a = new A();
  a.setFirstName("firstName " );
  a.setLastName("lastName " );
  
  AuditColumn auditColumn = AuditColumn.getInstance("USER");      
  a.setAuditColumn(auditColumn);
  
  session.save(a);
  </code></pre>
  
  <p>On Executing above code getting:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.PropertyValueException: not-null property references a null or transient value : com.bpk.hibernate.data.model.A.auditColumn.createDate
  </code></pre>
  
  <p>Is there any way to pass the default value of CreateDate of AuditColumn without setting the value through java?</p>