MultiTableInfo Foreign Key Mapping Leads to ORA-02291: integrity constraint violated - parent key not found
Last updated on JUNE 11, 2018
Applies to:Oracle TopLink - Version 10.1.3.3 and later
Information in this document applies to any platform.
***Checked for relevance on 15-Feb-2012***
***Checked for relevance on 27-Oct-2013***
Two tables are mapped with a one-to-many relationship (Master-Detail), using a MultiTableInfo descriptor.
With the given foreign key mappings, insertion into the tables using Toplink 10.1.3.3 fails with the following message:
However, when doing the same insertion with Toplink 9.0.4 API it works fine.
Here is an example structure of two such tables :
ID_PRC NUMBER(22) NOT NULL,
PRC_NAME VARCHAR2(50) NOT NULL,
PRC_SECONDARY_ID NUMBER(22) NOT NULL
CREATE TABLE SECONDARY (
ID_SCN NUMBER(22) NOT NULL,
CREATE SEQUENCE SN_WAT INCREMENT BY 1 START WITH 1;
ALTER TABLE PRINCIPAL ADD CONSTRAINT PK_PRINCIPAL PRIMARY KEY (ID_PRC) USING INDEX;
ALTER TABLE SECONDARY ADD CONSTRAINT PK_SECONDARY PRIMARY KEY (ID_SCN) USING INDEX;
ALTER TABLE PRINCIPAL ADD CONSTRAINT FK_SECONDARY FOREIGN KEY (PRC_SECONDARY_ID) REFERENCES SECONDARY (ID_SCN);
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms