Fix relationship on different contexts error when nested objects are inserted

This is a fix only concerning inserting non-existing nested objects before save, and persisting root and nested objects from the response.