title: hibernate and oracle sequence GenericGenerator creates gap
body: <p>I've mapped my class as follow (omitted other fields as only ID matters):</p>
  
  <pre><code>@Entity
  @Table(name = "MODEL_GROUP")
  @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
  public class SettlementModelGroup implements Serializable
  {
  
  
  @Id
  @GeneratedValue(generator = "MODEL_GROUP_SEQ", strategy = GenerationType.SEQUENCE)
  @GenericGenerator(name = "MODEL_GROUP_SEQ",
          strategy = "sequence",
          parameters = @Parameter(name = "sequence", value = "SEQ_MODEL_GROUP_MODEL_GROUP_ID"))
  @Column(name = "MODEL_GROUP_ID", nullable = false)
  private Integer modelId;
  }
  </code></pre>
  
  <p>when I'm saving new object:</p>
  
  <pre><code>Integer modelGroupId = sessionFactory.getCurrentSession().save( modelGroup );
  System.out.println( modelGroupId );
  </code></pre>
  
  <p>ID is set as for example <code>23</code>, but when I look at the database it is actually <code>24</code>. This is leading to many problems, as I'm using this ID later on. Any idea why it is making this gap?</p>
  
  <p>SQL logs show that everything is fine (I thinks so):</p>
  
  <pre><code>Hibernate: 
   select
       SEQ_MODEL_GROUP_MODEL_GROUP_ID.nextval 
   from
       dual
  Hibernate: 
   insert 
   into
       MODEL_GROUP
       (DOMAIN_ID, DESCRIPTION, NAME, PERIOD_TYPE_ID, MODEL_GROUP_TYPE_ID, STATUS_ID, OWNER_ID, MODEL_GROUP_ID) 
   values
       (?, ?, ?, ?, ?, ?, ?, ?)
  </code></pre>
  
  <p>Trigger and Sequence:</p>
  
  <pre><code>CREATE SEQUENCE "SEQ_MODEL_GROUP_MODEL_GROUP_ID" 
    INCREMENT BY 1 
    START WITH 1 
    NOMAXVALUE 
    MINVALUE 1 
   NOCYCLE 
   NOCACHE 
   NOORDER
  ;
  
  CREATE OR REPLACE TRIGGER "TRG_MODEL_GROUP_MODEL_GROUP_ID" 
  BEFORE INSERT 
  ON "MODEL_GROUP" 
  FOR EACH ROW 
  WHEN (NEW."MODEL_GROUP_ID" is NULL)
  BEGIN 
      SELECT "SEQ_MODEL_GROUP_MODEL_GROUP_ID".NEXTVAL 
      INTO :NEW."MODEL_GROUP_ID" 
      FROM DUAL; 
  END;
  </code></pre>