//Rollback Transaction 원형 private static void RollbackTransactionCore(ISqlMapper mapper) { if (mapper.IsSessionStarted) { ISqlMapSession session = mapper.LocalSession; if (session.IsTransactionStart) { session.RollBackTransaction(); } } }
/// <summary> /// 封装了对应的SqlMap的方法,以事务的方式批量删除 /// </summary> /// <param name="statementNames"></param> /// <param name="parameterObjects"></param> /// <returns></returns> protected object[] ExecuteBatchDelete(IList <string> statementNames, IList <object> parameterObjects) { Debug.Assert(statementNames.Count == parameterObjects.Count, "语句和参数的个数不匹配"); ISqlMapper sqlMap = GetLocalSqlMap(); var results = new object[statementNames.Count]; if (sqlMap.IsSessionStarted) { sqlMap.CloseConnection(); } using (ISqlMapSession sqlMapSession = sqlMap.BeginTransaction()) { try { for (int i = 0; i < statementNames.Count; i++) { results[i] = sqlMap.Delete(statementNames[i], parameterObjects[i]); } sqlMapSession.CommitTransaction(); } catch (Exception e) { Trace.Write(e.Message + "\n" + e.StackTrace); sqlMapSession.RollBackTransaction(); throw new IBatisNetException( "Error executing batch query '" + statementNames[0] + "' for delete. Cause: " + e.Message, e); } } return(results); }
public void Dispose() { if (_isCommit) { return; } if (null == _mappedSession) { System.Runtime.Remoting.Messaging.CallContext.SetData(_name, false); } else { if (_isOwnerSession) { _dbSession.GetMapper().RollBackTransaction(); } else { _mappedSession.RollBackTransaction(); } System.Runtime.Remoting.Messaging.CallContext.SetData(_name, null); } }
public void Rollback() { _tran.RollBackTransaction(); }
public void Rollback() { _sqlMapSession.RollBackTransaction(); _complete = true; }