title: hibernate ID increment oracle
body: <p>I managed to let hibernate increment the id of every table by 1 by putting this into every entity class. </p>
  
  <pre><code>@Entity
  public class TestObject implements Serializable{
  
  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="idgen")
  @SequenceGenerator(
          name="idgen",
          sequenceName="testobject_seq",
          allocationSize=1,
          initialValue=1
      )
  </code></pre>
  
  <p>I have two tables which i fill with data manually through the Oracle SQL Developer. After i created the tables.</p>
  
  <pre><code>&lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
  </code></pre>
  
  <p>For the 2 tables with data in it i set the initialValue to what i need.
  For instance, table testchamber has 22 rows with data. So my annotation changes to this:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="idgen")
  @SequenceGenerator(
          name="idgen",
          sequenceName="testchamber_seq",
          allocationSize=1,
          initialValue=23
      )
  </code></pre>
  
  <p>But when i try to save a new testChamber entity i get this error.</p>
  
  <pre><code>org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session
  </code></pre>
  
  <p>I could save my entity without a problem before i changed the annotation but with the old annotation hibernate incremented the id randomly. For instance, hibernate gave a new entity the id 60, 61 instead of 23, 24 and so on..</p>
  
  <p>This was my old annotation:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE)
  </code></pre>
  
  <ul>
  <li>Is there a correct way, to tell hibernate that a table has already
  data in it and it should start to count form a specific number?</li>
  <li>or how can i get rid of the "NonUniqueObjectException".</li>
  </ul>