Foreign Key Constraint Fails

Hello,

 

I have a user input task, a script task to set data,and a write to data store node that were in a large process model. Everything worked fine and write to the DB fine as well. To make things easier, I decided to put these three nodes in its own subprocess. Copied and pasted everything into the subprocess however, as soon as I ran this new process, I got this error and now the data store write isn't happening. Any idea why?

 An error occurred while trying to write to the entity “USER_INFO” [id=24fe567f-17c1-4a15-9f72-a88f6036ebe7@4344, type=USER_INFO (id=6362)] (data store: App Data). Details: org.hibernate.exception.ConstraintViolationException: could not insert: [USERINFODT6973]: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`Appian`.`USER_INFO`, CONSTRAINT `USER_INFO_fk_1` FOREIGN KEY (`USER_ID`) REFERENCES `CORE_Appian_User` (`USER_ID`)) Data: TypedValue[it=6362,v={<null>,0,,,,,,,,,2018-02-08,,<null>}] 

  Discussion posts and replies are publicly visible

Parents
  • Hi Ck,

    Can you please check your CDT mapping? it should be as shown below for foreign key mapping:

    <xsd:schema xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:tns="urn:com:appian:types:mainTable" targetNamespace="urn:com:appian:types:mainTable">
    <xsd:include schemaLocation="%7Burn%3Acom%3Aappian%3Atypes%3A7DsubTable.xsd" />
    <xsd:complexType name="Main_Table">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
    @Table(name="Main_Table")
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
    <xsd:element name="id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@Id @Column(name="ID", columnDefinition="int", nullable=false) @GeneratedValue</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="subTable" type="tns:subTable">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@OneToMany(indexed=false) @JoinColumn(name="mainTableID", nullable=false)</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>

    The above mapping will automatically set the main table's id as a foreign key on the sub table to the mapped column(mainTableID).
Reply
  • Hi Ck,

    Can you please check your CDT mapping? it should be as shown below for foreign key mapping:

    <xsd:schema xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:tns="urn:com:appian:types:mainTable" targetNamespace="urn:com:appian:types:mainTable">
    <xsd:include schemaLocation="%7Burn%3Acom%3Aappian%3Atypes%3A7DsubTable.xsd" />
    <xsd:complexType name="Main_Table">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
    @Table(name="Main_Table")
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
    <xsd:element name="id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@Id @Column(name="ID", columnDefinition="int", nullable=false) @GeneratedValue</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="subTable" type="tns:subTable">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@OneToMany(indexed=false) @JoinColumn(name="mainTableID", nullable=false)</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>

    The above mapping will automatically set the main table's id as a foreign key on the sub table to the mapped column(mainTableID).
Children
No Data