title: Configure Hibernate to use Oracle's SYS_GUID() for Primary Key
body: <p>I am looking for a way to get hibernate to use oracle's <code>SYS_GUID()</code> function when inserting new rows. Currently my DB tables have <code>SYS_GUID()</code> as the default so if hibernate simply generated SQL that omited the value it should work.</p>
  
  <p>I have everything working, but it is currently generating the UUID/GUID in code using the system-uuid generator:</p>
  
  <pre><code>@Id
  @GeneratedValue(generator = "system-uuid")
  @GenericGenerator(name = "system-uuid", strategy = "uuid")
  @Column(name = "PRODUCT_ID", unique = true, nullable = false)
  public String getId() {
      return this.productId;
  }
  </code></pre>
  
  <p>This is fine, but I would prefer that the guids were generated by the database so they will be sequential and potentially have better performance. Plus I would just like to know how to configure this.</p>
  
  <p>I am using annotations for configuration, but xml configuration examples are awesome as well. </p>
  
  <p><em>Here is a sample table definition (in case it matters):</em></p>
  
  <pre><code>CREATE TABLE SCHEMA_NAME.PRODUCT
  (
      PRODUCT_ID RAW(16) DEFAULT SYS_GUID() NOT NULL,
      PRODUCT_CODE VARCHAR2(10 CHAR) NOT NULL,
      PRODUCT_NAME VARCHAR2(30 CHAR) NOT NULL,
      PRODUCT_DESC VARCHAR2(512 CHAR)
  )
  </code></pre>
  
  <h2>UPDATE:</h2>
  
  <p>Mat's sollution of using "guid" worked, here is the sql generated:</p>
  
  <pre><code>Hibernate: 
      select rawtohex(sys_guid()) 
      from dual
  Hibernate: 
      insert into PRODUCT
      (PRODUCT_CODE, PRODUCT_DESC, LOB_ID, PRODUCT_NAME, PROVIDER_ID, PRODUCT_ID) 
      values (?, ?, ?, ?, ?, ?)
  </code></pre>
  
  <hr>
  
  <p><strong>It seems that using the columns default value in an insert is not possible, so the choice is between an application generated guid and a database round trip.</strong></p>