예제 #1
0
  @Override
  protected Result hook_call(Context ctx) throws Throwable {
    // TODO make it possible to get an extra transaction (either nested, or separate)
    // TODO allow for transactions across multiple requests
    boolean successful = false;
    try {
      Ebean.beginTransaction();

      Result result = delegate.call(ctx);
      successful = true;
      return result;
    } finally {
      // if running tests, don't commit
      if (AppContext.Mode.isRunningTests() || !successful) {
        Ebean.rollbackTransaction();
      } else {
        // TODO do retry logic
        Ebean.commitTransaction();
      }
    }
  }
 private void rollbackTransactionSilent() {
   try {
     Ebean.rollbackTransaction();
   } catch (Exception e) {
   }
 }