/** * If the current transaction has already been committed do nothing * otherwise rollback the transaction. * <p> * Useful to put in a finally block to ensure the transaction is ended, * rather than a rollbackTransaction() in each catch block. * </p> * <p> * Code example: * </p> * * <pre class="code"> * Ebean.beginTransaction(); * try { * // do some fetching and or persisting * // commit at the end Ebean.commitTransaction(); * * } finally { * // if commit didn't occur then rollback the transaction * Ebean.endTransaction(); * } * </pre> */ public static void endTransaction() { serverMgr.getPrimaryServer().endTransaction(); }
/** * If the current transaction has already been committed do nothing otherwise * rollback the transaction. * <p> * Useful to put in a finally block to ensure the transaction is ended, rather * than a rollbackTransaction() in each catch block. * </p> * <p> * Code example: * </p> * * <pre class="code"> * Ebean.beginTransaction(); * try { * // do some fetching and or persisting * // commit at the end Ebean.commitTransaction(); * * } finally { * // if commit didn't occur then rollback the transaction * Ebean.endTransaction(); * } * </pre> */ public static void endTransaction() { serverMgr.getPrimaryServer().endTransaction(); }
/** * If the current transaction has already been committed do nothing otherwise * rollback the transaction. * <p> * Useful to put in a finally block to ensure the transaction is ended, rather * than a rollbackTransaction() in each catch block. * </p> * <p> * Code example: * </p> * <pre>{@code * Ebean.beginTransaction(); * try { * // do some fetching and or persisting * * // commit at the end * Ebean.commitTransaction(); * * } finally { * // if commit didn't occur then rollback the transaction * Ebean.endTransaction(); * } * }</pre> */ public static void endTransaction() { serverMgr.getDefaultServer().endTransaction(); }
@Override public void endTransaction() { methodCalls.add(MethodCall.of("endTransaction")); delegate.endTransaction(); }
@Override protected void doEndTxIfActive(Object delegate) { Transaction tx = ebean.currentTransaction(); if (null == tx) { return; } if (TxContext.readOnly()) { ebeanReadOnly.endTransaction(); } else { ebean.commitTransaction(); } }
@Override protected void doRollbackTx(Object delegate, Throwable cause) { Transaction tx = ebean.currentTransaction(); if (null == tx) { return; } if (TxContext.readOnly()) { ebeanReadOnly.endTransaction(); } else { logger.warn(cause, "Roll back transaction"); ebean.rollbackTransaction(); } }
db.endTransaction(); } catch (Exception e) { log.log(Level.WARNING,