title: How to Auto generate UUID value for non-primary key using JPA
body: <p>I have Spring boot application where I am using JPA layer to talk to PostgreSQL. I have a non-primary key of type UUID which I want to auto generate on call of save method. I annotated the attribute with @GeneratedValue but the column value is null on insert.</p>
  <pre><code>@Column(name = &quot;USER_UUID&quot;)
  @GeneratedValue(strategy = GenerationType.AUTO)
  private UUID userUuid;
  </code></pre>
  <p>Also I have created the column as:</p>
  <pre><code>ADD COLUMN IF NOT EXISTS user_uuid uuid UNIQUE DEFAULT uuid_generate_v4();
  </code></pre>
  <p>How to auto generate the non-primary UUID value in this case?</p>