Q: org.h2.table.Column.updateSequenceIfRequired results in java.lang.NumberFormatException when inserting a row in H2 database using JPA Thank you in advance for investing time in trying to help.
Context:

*

*I am using Spring-boot with H2 database.

I am trying to insert a row, the very first row, into a table and that results in a NumberFormatException when the String value of an Identifier column (id) is attempted to be converted into a Long. I am sure there is a logical explanation of this behavior, but I don't understand why a column with a String type (id) is attempted to be converted into a long. I take that that id is attempted to be incremented, but I do not understand why. According to https://docs.jboss.org/hibernate/orm/5.0/mappingGuide/en-US/html/ch06.html, a valid type for Identifiers includes String. I would like to know what is causing this problem.
This is my table schema:
CREATE TABLE events (
  specversion VARCHAR(5),
  type        VARCHAR(50),
  source      VARCHAR(50),
  subject     VARCHAR(50),
  id          VARCHAR(10) IDENTITY PRIMARY KEY,
  time        TIMESTAMP,
  datacontenttype VARCHAR(50),
  data        VARCHAR(1048576)
);
CREATE INDEX events_id ON events (id);

This is my entity class:
@Getter
@Setter
@Entity
@Table(name = "events")
public class Event {

    @Column(name = "specversion")
    private String specversion;

    @Column(name = "type")
    private String type;

    @Column(name = "source")
    private String source;

    @Column(name = "subject")
    private String subject;

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "time")
    private OffsetDateTime time;

    @Column(name = "datacontenttype")
    private String datacontenttype;

    @Column(name = "data")
    private String data;

}


This is my Repository interface:
import org.springframework.data.repository.Repository;

public interface EventRepository extends Repository<Event, String> {

    void save(Event event);

}


When creating an instance of Event I am setting id to "Id1":
event.setId("Id1");

This is the stack trace:
java.lang.NumberFormatException: For input string: "Id1"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68) ~[na:na]
at java.base/java.lang.Long.parseLong(Long.java:707) ~[na:na]
at java.base/java.lang.Long.parseLong(Long.java:832) ~[na:na]
at org.h2.value.Value.convertToLong(Value.java:1011) ~[h2-1.4.200.jar:1.4.200]
at org.h2.value.Value.convertTo(Value.java:808) ~[h2-1.4.200.jar:1.4.200]
at org.h2.value.Value.convertTo(Value.java:737) ~[h2-1.4.200.jar:1.4.200]
at org.h2.value.Value.getLong(Value.java:627) ~[h2-1.4.200.jar:1.4.200]
**at org.h2.table.Column.updateSequenceIfRequired(Column.java:416)

A: The IDENTITY keyword automatically generating an incrementing 64-bit long integer as id of table.
You dont have to pass id attribute, it will be auto generated.
Or remove IDENTITY keywork from script.
CREATE TABLE events (
  specversion VARCHAR(5),
  type        VARCHAR(50),
  source      VARCHAR(50),
  subject     VARCHAR(50),
  id          VARCHAR(10) PRIMARY KEY,
  time        TIMESTAMP,
  datacontenttype VARCHAR(50),
  data        VARCHAR(1048576)
);
CREATE INDEX events_id ON events (id);

