title: Hibernate/Oracle: How to make sequence execute within insert statement instead of two queries
body: <p>I come from a jdbc background and I decided to teach myself to use hibernate. So I made a table with a sequence:</p>
  
  <pre><code>CREATE TABLE TST_PERSON(
  ID NUMBER,
  NAME VARCHAR(30),
  SURNAME VARCHAR(30)
  );
  
  CREATE SEQUENCE TST_PERSON_SEQ MINVALUE 1 MAXVALUE 999999999999999999999999999 
  INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER  NOCYCLE ;
  </code></pre>
  
  <p>and my java code for the mapping:</p>
  
  <pre><code>@Entity
  @Table(name="TST_PERSON")
  public class Person {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO,generator="pers_seq")
      @SequenceGenerator(name="pers_seq",sequenceName="TST_PERSON_SEQ")
      private Long id;
  
      @Column(name="NAME")
      private String name;
  
      @Column(name="SURNAME")
      private String surname;
      ... getters and setters ...
  }
  </code></pre>
  
  <p>My hibernate configuration is:</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='utf-8'?&gt;
      &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
      &lt;hibernate-configuration&gt;
          &lt;session-factory&gt;
              &lt;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
              &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@localhost:1521:sid&lt;/property&gt;
              &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
              &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
              &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;
              &lt;property name="show_sql"&gt;true&lt;/property&gt;
              &lt;property name="dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/property&gt;
              &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
              &lt;mapping class="com.domain.Person"/&gt;
          &lt;/session-factory&gt;
      &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>But when I look at the SQL generated by Hibernate logs when calling session.save:</p>
  
  <pre><code>Hibernate: select TST_PERSON_SEQ.nextval from dual
  Hibernate: insert into TST_PERSON (NAME, SURNAME, id) values (?, ?, ?)
  </code></pre>
  
  <p>I thought there might be some caching reasons but when I try to save through a loop I get the same output.</p>
  
  <p>So the question is how do I get hibernate to include the sequence as part of the insert statement (which is what I intended to happen). In terms of versions I am using hibernate 4.1.8</p>