title: How to generate GUID on demand in hibernate?
body: <p>I want to generate a GUID id, if user didn't give a name for <code>COMPONENT</code>, </p>
  
  <pre><code>@Entity class Component {
  
      @Id @Column(length = 32)
      String name; 
  
  }
  </code></pre>
  
  <p>I can't use generator here, so I can explicit specify the name.</p>
  
  <p>Though I can add another id field, and make name as @NaturalId:</p>
  
  <pre><code>@Entity class Component {
  
      @Id
      Long id;
  
      @Column(length = 32)
      String name; 
  
  }
  </code></pre>
  
  <p>But the question still: How can I generate a GUID for name?</p>
  
  <p>I can write a simple GUID generator myself, but I want to do it Hibernate way.</p>