public void ToIsolationLevel() { Assert.AreEqual(IsolationLevel.Unspecified, HsqlConvert.ToIsolationLevel(HsqlIsolationLevel.None)); Assert.AreEqual(IsolationLevel.ReadCommitted, HsqlConvert.ToIsolationLevel(HsqlIsolationLevel.ReadCommited)); Assert.AreEqual(IsolationLevel.ReadUncommitted, HsqlConvert.ToIsolationLevel(HsqlIsolationLevel.ReadUncommited)); Assert.AreEqual(IsolationLevel.RepeatableRead, HsqlConvert.ToIsolationLevel(HsqlIsolationLevel.RepeatableRead)); Assert.AreEqual(IsolationLevel.Serializable, HsqlConvert.ToIsolationLevel(HsqlIsolationLevel.Serializable)); }
public override void EnlistTransaction(Transaction systemTransaction) { lock (m_syncRoot) { CheckClosed(); if (systemTransaction == null) { throw new ArgumentNullException("transaction"); } HsqlEnlistment enlistment = m_enlistment; if (enlistment == null) { enlistment = new HsqlEnlistment(this, systemTransaction); if (!systemTransaction.EnlistPromotableSinglePhase(enlistment)) { if (m_transaction == null) { BeginTransaction(HsqlConvert.ToIsolationLevel(systemTransaction.IsolationLevel)); } enlistment.m_dbTransaction = m_transaction; systemTransaction.EnlistDurable(enlistment.Rmid, enlistment, EnlistmentOptions.None); } m_enlistment = enlistment; GC.KeepAlive(this); } else if (enlistment.Transaction != systemTransaction) { throw new InvalidOperationException( "Connection currently has transaction enlisted." + " Finish current transaction and retry."); // NOI18N } } }
/// <summary> /// Notifies the transaction participant that the enlistment has completed successfully. /// </summary> /// <exception cref="TransactionException"> /// When an attempt to enlist or serialize the transaction fails. /// </exception> void IPromotableSinglePhaseNotification.Initialize() { m_dbTransaction = m_dbConnection.BeginTransaction( HsqlConvert.ToIsolationLevel(m_systemTransaction.IsolationLevel)); }