From dc33995ee960dcf2bf83ee6fe5a72cf70e90bf7c Mon Sep 17 00:00:00 2001 From: Bruno Holliger <53424771+BrunoHolliger@users.noreply.github.com> Date: Fri, 31 Jan 2020 13:20:50 +0100 Subject: [PATCH] Prevent cloning from non-existing objects If there is an orphaned relationship in a link table, do not try to get a clone of the object, as this will fail badly. Please review and include in further revisions. Thank you very much! --- src/CommunityCommons/javasource/communitycommons/ORM.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CommunityCommons/javasource/communitycommons/ORM.java b/src/CommunityCommons/javasource/communitycommons/ORM.java index 8458108..45600b9 100644 --- a/src/CommunityCommons/javasource/communitycommons/ORM.java +++ b/src/CommunityCommons/javasource/communitycommons/ORM.java @@ -102,8 +102,11 @@ private static void duplicate(IContext ctx, IMendixObject src, IMendixObject tar List res = new ArrayList(); for (IMendixIdentifier item : rs.getValue(ctx)) { IMendixObject o = Core.retrieveId(ctx, item); - IMendixIdentifier refObj = getCloneOfObject(ctx, o, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects); - res.add(refObj); + // Do not try to clone a non-existing object + if (null != o) { + IMendixIdentifier refObj = getCloneOfObject(ctx, o, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects); + res.add(refObj); + } } tar.setValue(ctx, key, res); } else if (m instanceof MendixAutoNumber) //skip autonumbers! Ticket 14893