"A child row has multiple parents" error

In a load data step of a workflow I get an error message “A child row has multiple parents.” I have no idea what could be the problem…?

Spoiler: Check your entity relation IsParentChild and change it to false

Reason

You are trying to enforce nested XML in case where nesting would introduce repeating of the same data. This can happen basically anytime you set IsParentChild = True in cases where the relation is actually NOT a parent child but more a foreign key.

Example

Order Data Structure

  • OrderEntity
    • BusinessPartnerEntity

Business partner is obviously a foreign key, let’s say OrderEntity.refBusinessPartnerEntityId.

If you set IsParentChild = True on the BusinessPartnerEntity relation you would get the following XML:

<OrderEntity Id="ord1">
   <!-- there will be just 1 BusinessPartnerEntity because it is not acutally a child but a foreign key of OrderEntity -->
   <BusinessPartnerEntity Id="bp1"/>
</OrderEntity>
<OrderEntity Id="ord2">
   <!-- Second order has the same business partner assigned -->
   <BusinessPartnerEntity Id="bp1"/>
</OrderEntity>

As you can see BusinessPartnerEntity Id=“bp1” is now duplicated in the XML.

Duplicating data in XML is forbidden (see https://www.origam.com/doc/display/architect/Relationships). It would make updating a problem (which of the XML elements would be used to update the data?).

Solution

So the solution is to turn off IsParentChild on the “foreign key” kind of relationship.

Workaround

If you really MUST have nested relations repeating (e.g. for outputting to an API call or exporting data to a different system, where you will not need data updates, you need to transform the data using an XSLT transformation and you must do it through an XSD Data Structure (e.g. _any from the Root package).

1 Like