1. 程式人生 > >為什麼session.close(),之後不進行事務回滾

為什麼session.close(),之後不進行事務回滾

public void close() {
    try {
      executor.close(isCommitOrRollbackRequired(false));
//這裡將dirty變為假
      dirty = false;
    } finally {
      ErrorContext.instance().reset();
    }
  }
public void commit(boolean force) {
    try {
//導致commit(為假)
      executor.commit(isCommitOrRollbackRequired(force));
      dirty = false;
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error committing transaction.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
    }
  }
public void commit(boolean required) throws SQLException {
    if (closed) throw new ExecutorException("Cannot commit, transaction is already closed");
    clearLocalCache();
    flushStatements();
//required為假,不進行回滾
    if (required) {
      transaction.commit();
    }
  }