title: Hibernate not getting increment correctly from database
body: <p>Trying to run my Spring Boot application but Hibernate has the wrong increment: <strong>The increment size of the [exercise_id_seq] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1]</strong>
  I used Flyway migration to create my entities.</p>
  <pre><code>create sequence exercise_id_seq start with 1 increment 1;
  
  create table exercise
  (
      id              bigint        not null primary key,
      content         varchar(1000) not null,
      content_latex   varchar(1000) not null,
      exercise_type   varchar(1000) not null,
      solution_latex  varchar(1000),
      solution_number decimal(10, 2),
      points          integer,
      test_only       boolean,
      instructions    varchar(3000),
      created         timestamp     NOT NULL,
      modified        timestamp     NOT NULL,
      creator         varchar(255)  NOT NULL,
      modifier        varchar(255)  NOT NULL
  );
  
  </code></pre>
  <p>And have my entity as:</p>
  <pre><code>@Setter
  @Getter
  @Entity
  @Table(name = &quot;exercise&quot;)
  public class Exercise extends EntityBase {
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;exercise_id_seq&quot;)
      @SequenceGenerator(initialValue = 1,sequenceName = &quot;exercise_id_seq&quot;, name = &quot;exercise_seq&quot;, allocationSize = 1)
      private Long id;
  
      private String content;
      private String contentLatex;
      private String exerciseType;
      private String solutionLatex;
      private BigDecimal solutionNumber;
      private Long points;
      private Boolean testOnly;
      private String instructions;
  }
  
  </code></pre>
  <p>Stacktrace:</p>
  <pre><code>    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:147) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:359) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:280) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.internal.SessionFactoryImpl.lambda$new$1(SessionFactoryImpl.java:306) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
      at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
      at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:305) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.17.jar:5.3.17]
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.17.jar:5.3.17]
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.17.jar:5.3.17]
      ... 25 common frames omitted
  Caused by: org.hibernate.MappingException: The increment size of the [exercise_id_seq] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1].
      at org.hibernate.id.enhanced.SequenceStyleGenerator.configure(SequenceStyleGenerator.java:262) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
      at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:142) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]```
  
  Any ideas?
  </code></pre>