title: Spring JPA using H2 and Hibernate doesn't auto increment correctly
body: <p>Attempting to insert a new row in a table with already existing rows gives me a primary key violation since the counter doesn't increment properly. </p>
  
  <p>I'm trying to insert a new row into a table which already contains two rows using Spring CrudRepository. It works fine if the database is empty, then the counter will work as intended, the problem occurs when the database is modified from outside the Spring Application, it seems like the counter gets lost. </p>
  
  <p>The table </p>
  
  <pre><code>CREATE TABLE apiusers (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(250) NOT NULL,
    email VARCHAR(250) NOT NULL,
    apikey VARCHAR(250) NOT NULL
  );
  </code></pre>
  
  <p>The POJO:</p>
  
  <pre><code>@Entity
  @Table(name = "apiusers")
  @Data
  public class ApiUser {
  
      @Id
      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "APIUSERS_PK_SEQ")
      private Long id;
  
      private String name;
      private String email;
      private String apikey;
  
      public ApiUser() {
      }
  
      public ApiUser(String name, String email, String apikey) {
          this.name = name;
          this.email = email;
          this.apikey = apikey;
      }
  }
  </code></pre>
  
  <p>The error I'm getting is:
  Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.APIUSERS(ID) [1, 'test', 'bla@gmail.com', '910e41bd-592d-4a96-a27e-cca45da762d1']"; SQL statement:</p>
  
  <p>This is caused because Spring is trying to insert the row with the same ID as the last row, causing a conflict.</p>
  
  <p>Also, I've tried @GeneratedValue(strategy=GenerationType.AUTO) without any luck.</p>
  
  <p>It seems like Spring doesn't properly sync the counter with the database..</p>