Hi,
we have a database which was migrated several times by different h2 and model versions up to the newest h2 and schema version. On a new created h2 database with the same schema the "Referential integrity constraint violation" will not come up.
shorted ddl:
CREATE TABLE "PUBLIC"."TERMEJB"
(
ID integer PRIMARY KEY NOT NULL,
MASTERTERM_ID integer,
[.... many other columns]
);
FOREIGN KEY (MASTERTERM_ID) REFERENCES "PUBLIC"."TERMEJB"(ID);
Data:
INSERT INTO "PUBLIC"."TERMEJB" (ID,MASTERTERM_ID, [...other columns]) VALUES (2754, NULL, [...]);
Failing query:
UPDATE TERMEJB SET MASTERTERM_ID = 2754 WHERE (ID = 2754)
causes:
Error: Referential integrity constraint violation: "FK_TERMEJB_MASTERTERM_ID: PUBLIC.TERMEJB FOREIGN KEY(MASTERTERM_ID) REFERENCES PUBLIC.TERMEJB(ID) (2754)"; SQL statement:
UPDATE TERMEJB SET MASTERTERM_ID = 2754 WHERE (ID = 2754) [23503-173]
SQLState: 23503
ErrorCode: 23503
Is the attached database corrupt or is there a bug in h2?
Is there any possiblility to fix the database programmatically?
thx
Ralf