Skip to content

Commit 6fedced

Browse files
committed
Add overload to ORM.cloneObject that can be used to skip 1-on-1 associations
1 parent a4c7fc3 commit 6fedced

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • src/CommunityCommons/javasource/communitycommons

src/CommunityCommons/javasource/communitycommons/ORM.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ private static boolean isFileDocument(IMendixObject object) {
265265

266266
public static Boolean cloneObject(IContext c, IMendixObject source,
267267
IMendixObject target, Boolean withAssociations) {
268+
return cloneObject(c, source, target, withAssociations, false);
269+
}
270+
271+
public static Boolean cloneObject(IContext c, IMendixObject source,
272+
IMendixObject target, Boolean withAssociations, Boolean skipIsBoth) {
268273
Map<String, ? extends IMendixObjectMember<?>> members = source.getMembers(c);
269274

270275
for (var entry : members.entrySet()) {
@@ -279,6 +284,10 @@ public static Boolean cloneObject(IContext c, IMendixObject source,
279284
continue;
280285
}
281286
if (withAssociations || ((!(m instanceof MendixObjectReference) && !(m instanceof MendixObjectReferenceSet) && !(m instanceof MendixAutoNumber)))) {
287+
if (skipIsBoth && (
288+
(m instanceof MendixObjectReference && ((MendixObjectReference) m).isBoth()) ||
289+
(m instanceof MendixObjectReferenceSet && ((MendixObjectReferenceSet) m).isBoth())))
290+
continue;
282291
target.setValue(c, entry.getKey(), m.getValue(c));
283292
}
284293
}

0 commit comments

Comments
 (0)