title: hibernate 5 sequencegenerator not giving the right value
body: <p>After migrating to Hibernate 5.2.7, I seem to be getting incorrect values for the id field.</p>
  
  <p>My code:</p>
  
  <pre><code>@Id @SearchableId
  @GeneratedValue(strategy=GenerationType.AUTO, generator="hms_seq_gen")
  @SequenceGenerator(name="hms_seq_gen", sequenceName="patregn_seq")
  protected Integer ID;
  </code></pre>
  
  <p>Hibernate fires this query: </p>
  
  <p><code>select nextval ('patregn_seq')</code> <br/>
  which gives 5367. The last value in the id field in the table is 5358.</p>
  
  <p>And I get this <br/>
  <code>ERROR: duplicate key value violates unique constraint "patientregistration_pkey"
       [java]   Detail: Key (id)=(5318) already exists.</code></p>
  
  <p>I am sure this question is similar to <a href="https://stackoverflow.com/questions/12745751/hibernate-sequencegenerator-and-allocationsize">this</a> and <a href="https://stackoverflow.com/questions/12737092/is-there-a-way-to-dynamically-choose-a-generatedvalue-strategy-using-jpa-annota">this</a>, but I am forced to ask because the solution given there does not work for me:</p>
  
  <p>I added </p>
  
  <p><code>&lt;property value="true" name="hibernate.id.new_generator_mappings"/&gt;</code></p>
  
  <p>to my persistence.xml, but to no avail. Any help would be greatly appreciated.</p>