/// <summary> /// Rolls back an uncommitted transaction when the object is disposed. /// </summary> public void Dispose() { if (Hibernator.HasOpenSession(SessionFactoryName)) { if ((!Transaction.WasCommitted) && (!Transaction.WasRolledBack)) { Hibernator.RollbackTransaction(SessionFactoryName); } } }
/// <summary> /// Commit the transaction. /// </summary> /// <remarks> /// If an exception is thrown during transaction commit, a rollback is /// automatically attempted before the exception bubbles up further. /// </remarks> public void Commit() { try { Hibernator.CommitTransaction(SessionFactoryName); } catch (Exception ex) { Hibernator.RollbackTransaction(SessionFactoryName); throw new HibernationException("An exception occurred while attempting to commit the transaction. Transaction has been rolled back.", ex); } }
/// <summary> /// Roll back the transaction. /// </summary> public void Rollback() { Hibernator.RollbackTransaction(SessionFactoryName); }