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

-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/CAG6_yCDrM96BMX4Da2SF%2BYU78s%2BifwX3g4avkcBZLbrDsXnGVw%40mail.gmail.com.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to