title: using oracle sequences with jpa (toplink)
body: <p>I have a sequence object in my oracle db:</p>
  
  <pre><code>create sequence BASE_SEQ
  minvalue 1
  maxvalue 9999999999999999999999999999
  start with 100
  increment by 1
  nocache;
  </code></pre>
  
  <p>I use jpa(toplink) for my web application. I have base class for all my db objects:</p>
  
  <pre><code>@MappedSuperclass
  @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
  
  public class AbstractEntity implements Serializable {
      protected BigDecimal id;
  
      @javax.persistence.Column(name = "ID")
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BASE_SEQ")
      @SequenceGenerator(name="BASE_SEQ",sequenceName="BASE_SEQ", catalog = "DOF")
      public BigDecimal getId() {
          return id;
      }
  </code></pre>
  
  <p>This class is inherited by some entities. After I start my application, and persist/merge several entities to db, i can find, that theirs' PK starts with 51 (instead of expected 100). </p>
  
  <p>After that, I go to my db, view DDL of my sequence object and see, that it has been changed to:</p>
  
  <pre><code>create sequence BASE_SEQ
  minvalue 1
  maxvalue 9999999999999999999999999999
  start with 101
  increment by 1
  nocache;
  </code></pre>
  
  <p>Why so happens? I have some entities with PK 51, 52 ... etc, and sequence starting with 101.</p>
  
  <p>AS - GlassFish 3.1.1</p>