From 50e6cb8d652f321032fee35ab8eef91781a15b16 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Wed, 25 Oct 2023 12:30:10 +0200 Subject: [PATCH] fix: auto-incremented save or merge --- .../axonivy/util/excel/importer/DialogProcess.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/excel-importer/src/com/axonivy/util/excel/importer/DialogProcess.java b/excel-importer/src/com/axonivy/util/excel/importer/DialogProcess.java index ec3a16f..221a22b 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/DialogProcess.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/DialogProcess.java @@ -100,8 +100,16 @@ private void addSaveAction() { var save = addEvent(); save.setName("save"); String doSave = """ - ivy.persistence.UNIT.merge(out.edit); - """.replaceAll("UNIT", unit); + if (!out.edit.#id is initialized) { + out.edit = ivy.persistence.UNIT.persist(out.edit) as ENTITY; + out.entries.add(out.edit); + } else { + ivy.persistence.UNIT.merge(out.edit); + } + out.edit = null; + """ + .replaceAll("UNIT", unit) + .replaceAll("ENTITY", entity.getName()); save.setOutput(new MappingCode(doSave)); }