/** * Run a block of code in a JPA transaction. * * @param block Block of code to execute */ public void withTransaction(final Runnable block) { try { withTransaction( "default", false, () -> { block.run(); return null; }); } catch (Throwable t) { throw new RuntimeException("JPA transaction failed", t); } }
/** * executes the runnable under only one transaction. Usefull to do various action overt the * application in one transaction * * @param runnable */ public void execute(final Runnable runnable) { runnable.run(); }