title: How are managed the sequences by JPA and Hibernate?
body: <p>I am using Hibernate in my project, and many of my entities use a sequence for their technical keys.
  For example:</p>
  
  <pre><code>@Entity
  @Table(name = "T_MYENTITY")
  @SequenceGenerator(name = "S_MYENTITY", sequenceName = "S_MYENTITY")
  public class MyEntity {
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_MYENTITY")
      @Column(name = "MY_ENTITY_ID")
      private Long entityId;
  
      ...
  
  }
  </code></pre>
  
  <p>I have two questions about the ID generated by Hibernate when a new object of this class is persisted:</p>
  
  <ol>
  <li>Why SequenceGenerator (from javax.persistence) has a default value of allocationSize set to 50 instead of 1? What are the interests of that?</li>
  <li>What is the default algorithm used by Hibernate to calculate the generated ID? It seems that Hibernate uses the value returned by the sequence hosted by my Oracle database, but then modify it before assigning it to my entity...</li>
  </ol>