0

I am receiving following XML structure:

<Parent>
    <Holding id="111"/>
    <Party id="yyy"/>
    <Party id="xxx"/>
    <Party id="zzz"/>
    <Relation partyRefId="xxx" holdingRefId="111"/>
    <Relation partyRefId="yyy" holdingRefId="111"/>
</Parent>

XML will be unmarshall to object model with the help of JAXB and I am saving it into the database using hibernate. So there is table for each element and column for each attribute.
Here Relation table has HoldingFK and PartyFK columns. In this
if Relation.holdingRefId == Holding.id
then Relation.HoldingFK is going to have database genearted HoldingPK and same will be applicable to Party too.
if Relation.partyRefId ==Party.id then Relation.PartyFk will have database specific PartyPK value.
Now JAXB is naturally creating an child array of Relation objects which can only have ParentFKs if persisted into database.
How can I add Relation objects as children of Holding or Party based on some condition?

Note: Here I have actual business terminology to make my query more understandable.
4

0 回答 0