Hi All, I am trying to understand and solve the root cause of the fol

Hi All,

I am trying to understand and solve the root cause of the following error:

An error occurred while trying to write to the entity “dealModuleStatusUpdate” [id=b2df0791-624a-4830-ae86-4800cb14d12a@7840, type=ICAMS_DealModulesStatusUpdate (id=3934)] (data store: ICAMS Datastore). Details: org.hibernate.exception.ConstraintViolationException: could not insert: [ICAMSDealModulesStatusUpdateDT1406]: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`Appian`.`ICAMS_DEAL_MODULES`, CONSTRAINT `ICAMS_DEAL_MODULES_ibfk_2` FOREIGN KEY (`SERIAL_NUMBER`) REFERENCES `ICAMS_MODULE` (`SERIAL_NUMBER`) ON UPDATE CASCADE) Data: TypedValue[it=3935,v={{2150,110332,23ML-77,1,2016-06-29 22:39:34.21,lewisro},{2151,110332,23ML-78,1,2016-06-29 22:39:34.21,lewisro},{2152,110332,23ML-79,1,2016-06-29 22:39:34.21,lewisro},{2153,110332,23ML-80,1,2016-06-29 22:39:34.21,lewisro},{21...

OriginalPostID-221106

OriginalPostID-221106

  Discussion posts and replies are publicly visible

  • ...54,110332,23ML-81,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,23ML-77-GB,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,23ML-78-GB,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,23ML-79-GB,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,23ML-80-GB,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,23ML-81-GB,1,2016-06-29 22:39:34.21,lewisro},{<null>,110332,138033,0,2016-06-29 22:39:34.3,lewisro},{<null>,110332,23ML-71-GB,0,2016-06-29 22:39:34.3,lewisro}}]

    Would really appreciate if anyone can share the solution for this.
  • I believe that a value you're entering into the ICAMS_DEAL_MODULES table's SERIAL_NUMBER column doesn't exist in the ICAMS_MODULE table. So if the serials numbers in the ICAMS_MODULE table are {1,2,3,4,5}, but you try to enter a row of data into ICAMS_DEAL_MODULES with a serial number of 6, then it will fail because it looks up the foreign key and can't find that value in the original table.
  • Thanks Lakshmim.
    I Have attached two images in the zip file. Capture.png shows the problem in the Datastore entity. Second image shows the values of two variables that I am writing to database. The first write to Data Store Entity Write "moduleAsShippedUpdates" to ICAMS_MODULE and second data store entity writes "dealModuleStatusUpdates" to ICAMS_DEAL_MODULES.

    So I am not able to understand the real problem here. I tested the same feature in my other environments i.e DEV and QA and it works perfectly fine.

    Foreign Constraint Error.zip

  • Sailesh,
    I think this is data issue. When I look at the screenshot 2, one value is missing in moduleAsShippedUpdates(23ML-71-GB). Check the data once.