Hi Team,
As part of the H2DB 1.4.199 to 2.2.224 migration we have faced a challenge in inserting data in a table where we are using auto_increment for the id.
My table with H2DB 1.4.199 is like below:
create table nim_entity_properties(
id int auto_increment,
entity_type varchar(40),
property_name varchar(50)
);
and when I am trying to insert the values with insert statement like below:
INSERT INTO `nim_entity_properties` (`id` ,`entity_type` ,`property_name` ) VALUES (null,'incident','custom123',);
The statement is executed fine with H2DB version 1.4.199 and it has inserted the value with an auto incremented id (existing rows count +1 )
However the same insert statement is giving an error like below with the H2DB 2.2.224 version.
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: NULL not allowed for column "ID"; SQL statement:
INSERT INTO `nim_entity_properties` (`id` ,`entity_type` ,`property_name` ) VALUES (?,?,?) [23502-224]
I have tried to alter the table column for id as below that was allowing the insert statement but it is giving a duplicate id 1 and the insertion successful. It is not adding 1 to the existing row count so that is not helpful for me .
So is there any way that we can get the auto_increment to consider null in the insert statement and generate an id for the new row and insert into DB successfully?
Thanks in advance.
Regards,
Balamurali