From ec56369019089824c2b8a2c3b4b92b7b75221211 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 6 Jan 2025 17:11:54 +0100 Subject: [PATCH] remove fast-persist mode, the advantage is negligible --- .../hsadminng/hs/migration/CsvDataImport.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java index 2006a470..049681e4 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java @@ -170,19 +170,18 @@ public class CsvDataImport extends ContextBasedTest { } public T persistViaEM(final Integer id, final T entity) { - //System.out.println("persisting #" + entity.hashCode() + ": " + entity); - if (!em.contains(entity)) { - em.persist(entity); + if (em.contains(entity)) { + return entity; + } + try { + em.persist(entity); + em.flush(); // makes it a bit slower, but produces better error messages + System.out.println("persisted #" + id + " as " + entity.getUuid()); + return entity; + } catch (final Exception exc) { + System.err.println("persist failed for #" + id + " as " + entity); + throw exc; // for breakpoints } - // uncomment for debugging purposes - // try { - // em.flush(); // makes it slow, but produces better error messages - // System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid()); - // return entity; - // } catch (final Exception exc) { - // throw exc; // for breakpoints - // } - return entity; } @SneakyThrows