Foreign Key reference integrity constraint errors

112 views Asked by At

We are running a script that creates data in one of the ClaimCenter tables. This table has a foreign key reference to contacts table, that we do not use.

We get an exception:

org.h2.jdbc.JdbcBatchUpdateException: Referential integrity constraint violation: CONSTRAINT_C7F2: PUBLIC.CCX_CLAIMCONTACTEMAILATTACHMENT_EXT FOREIGN KEY(CLAIMCONTACTID) REFERENCES PUBLIC.CC_CLAIMCONTACT(ID) SQLSTATE = 23506
SQL error code = 23506

Is there a way to create entries in CLAIMCONTACTEMAILATTACHMENT_EXT without creating on CC_CLAIMCONTACT or breaking this referential integrity and making it work?

We want to create records in CLAIMCONTACTEMAILATTACHMENT_EXT without creating on CC_CLAIMCONTACT.

1

There are 1 answers

0
SteveDrippsCentricConsulting On

I am assuming the following from your question:

  • ClaimContact has a 1 to N relationship with your custom ClaimContactEmailAttachment_Ext entity. This would mean that ClaimContact has an array of ClaimContactEmailAttachment_Ext defined in the ClaimContact.etx file and ClaimContactEmailAttachment_Ext has a foreignkey defined in the ClaimContactEmailAttachment_Ext.eti file
  • The new ClaimContactEmailAttachment_Ext entity is supposed to only be associated to a ClaimContact entity. The naming of the ClaimContactEmailAttachment_Ext seems to suggest this

If the 2 assumptions above are true then I think you should just modify your script to add the appropriate ClaimContact entities to the Claim in the same bundle that you are adding your ClaimContactEmailAttachment_Ext entities.

If, however, ClaimContactEmailAttachment_Ext is meant to be more of a admin type of data that can be used across multiple claims, then I would probably rename this entity to something more appropriate. If this is meant to be an admin data type, then there should not be a foreign key from this entity to a claim-level entity. The foreign key should be defined on the claim-level entity.