How to retain old associations when new values are mapped using REST service
I’m using REST service to bring in new values for 2 different entities. The entities are both associated with each other by a 1:many association. Suppose Entity A is associated with Entity B by 1:many association, which means multiple objects of Entity B can refer to a single object of Entity A. When the REST service brings in new values the objects are getting created properly and the association are set correctly. But if the REST service doesn’t have some old values of Entity B then the association from that object to the object of Entity A, which was set in a previous REST call, is getting broken. I see that the specific object of Entity B is not getting deleted but the association is getting deleted / broken. Can you please help me with how I can retain the association. Below are the screenshots for the mapping that I have. Do I need to change anything in the mapping setting?
I would suggest to create a non-persistent, temporary data structure where you store the result of the REST call.
After the call is completed you can then process the result and transform it to your target structure.
This approach will generate some more development overhead, but you can add additional plausibility checks and you have more control on the update of your persistent data.