From: Kevin W. <kev...@us...> - 2004-12-31 22:41:49
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12128 Modified Files: ITransactionFactory.cs Transaction.cs TransactionFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ITransactionFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/ITransactionFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ITransactionFactory.cs 20 Feb 2003 15:57:12 -0000 1.1 --- ITransactionFactory.cs 31 Dec 2004 22:41:39 -0000 1.2 *************** *** 1,20 **** - using System; using System.Collections; using NHibernate.Engine; - namespace NHibernate.Transaction { /// <summary> /// An abstract factory for <c>ITransaction</c> instances. (NHibernate note: do we need this??) /// </summary> ! public interface ITransactionFactory { /// <summary> /// Begin a transaction and return the associated <c>ITransaction</c> instance /// </summary> ! ITransaction BeginTransaction(ISessionImplementor session); /// <summary> /// Configure from the given properties /// </summary> ! void Configure(IDictionary props); } ! } --- 1,23 ---- using System.Collections; using NHibernate.Engine; + namespace NHibernate.Transaction + { /// <summary> /// An abstract factory for <c>ITransaction</c> instances. (NHibernate note: do we need this??) /// </summary> ! public interface ITransactionFactory ! { /// <summary> /// Begin a transaction and return the associated <c>ITransaction</c> instance /// </summary> ! /// <param name="session"></param> ! ITransaction BeginTransaction( ISessionImplementor session ); /// <summary> /// Configure from the given properties /// </summary> ! /// <param name="props"></param> ! void Configure( IDictionary props ); } ! } \ No newline at end of file Index: Transaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/Transaction.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Transaction.cs 5 Dec 2004 18:42:16 -0000 1.6 --- Transaction.cs 31 Dec 2004 22:41:39 -0000 1.7 *************** *** 1,7 **** using System; using System.Data; ! using NHibernate.Engine; ! namespace NHibernate.Transaction { /// <summary> --- 1,8 ---- using System; using System.Data; ! using log4net; using NHibernate.Engine; ! ! namespace NHibernate.Transaction { /// <summary> *************** *** 13,19 **** /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Transaction)); private ISessionImplementor session; private IDbTransaction trans; --- 14,20 ---- /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction { ! private static readonly ILog log = LogManager.GetLogger( typeof( Transaction ) ); private ISessionImplementor session; private IDbTransaction trans; *************** *** 22,39 **** private bool rolledBack; ! public Transaction(ISessionImplementor session) { this.session = session; } ! public void Enlist(IDbCommand command) { ! if( trans==null ) { ! if( log.IsWarnEnabled ) { ! if( command.Transaction!=null ) { ! log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); } } --- 23,48 ---- private bool rolledBack; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! public Transaction( ISessionImplementor session ) { this.session = session; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="command"></param> ! public void Enlist( IDbCommand command ) { ! if( trans == null ) { ! if( log.IsWarnEnabled ) { ! if( command.Transaction != null ) { ! log.Warn( "set a nonnull IDbCommand.Transaction to null because the Session had no Transaction" ); } } *************** *** 42,82 **** return; } ! else { ! if( log.IsWarnEnabled ) { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... ! if( command.Transaction!=null && command.Transaction!=trans ) { ! log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); } } ! ! command.Transaction = trans; } } ! public void Begin() { ! log.Debug("begin"); ! try { IsolationLevel isolation = session.Factory.Isolation; ! if( isolation==IsolationLevel.Unspecified ) { trans = session.Connection.BeginTransaction(); } ! else { trans = session.Connection.BeginTransaction( isolation ); } ! } ! catch( Exception e ) { ! log.Error("Begin transaction failed", e); ! throw new TransactionException("Begin failed with SQL exception", e); } --- 51,92 ---- return; } ! else { ! if( log.IsWarnEnabled ) { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... ! if( command.Transaction != null && command.Transaction != trans ) { ! log.Warn( "The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific." ); } } ! ! command.Transaction = trans; } } ! /// <summary></summary> ! public void Begin() { ! log.Debug( "begin" ); ! try { IsolationLevel isolation = session.Factory.Isolation; ! if( isolation == IsolationLevel.Unspecified ) { trans = session.Connection.BeginTransaction(); } ! else { trans = session.Connection.BeginTransaction( isolation ); } ! } ! catch( Exception e ) { ! log.Error( "Begin transaction failed", e ); ! throw new TransactionException( "Begin failed with SQL exception", e ); } *************** *** 84,114 **** } ! public void Commit() { ! if (!begun) { ! throw new TransactionException("Transaction not successfully started"); } ! log.Debug("commit"); ! try { ! if( session.FlushMode!=FlushMode.Never ) { session.Flush(); } ! try { trans.Commit(); committed = true; ! } ! catch( Exception e ) { ! log.Error("Commit failed", e); ! throw new TransactionException("Commit failed with SQL exception", e); } ! } ! finally { session.AfterTransactionCompletion(); --- 94,125 ---- } ! /// <summary></summary> ! public void Commit() { ! if( !begun ) { ! throw new TransactionException( "Transaction not successfully started" ); } ! log.Debug( "commit" ); ! try { ! if( session.FlushMode != FlushMode.Never ) { session.Flush(); } ! try { trans.Commit(); committed = true; ! } ! catch( Exception e ) { ! log.Error( "Commit failed", e ); ! throw new TransactionException( "Commit failed with SQL exception", e ); } ! } ! finally { session.AfterTransactionCompletion(); *************** *** 116,138 **** } ! public void Rollback() { ! if (!begun) { ! throw new TransactionException("Transaction not successfully started"); } ! log.Debug("rollback"); ! try { trans.Rollback(); rolledBack = true; ! } ! catch( Exception e ) { ! log.Error("Rollback failed", e); ! throw new TransactionException("Rollback failed with SQL Exception", e); ! } ! finally { session.AfterTransactionCompletion(); --- 127,150 ---- } ! /// <summary></summary> ! public void Rollback() { ! if( !begun ) { ! throw new TransactionException( "Transaction not successfully started" ); } ! log.Debug( "rollback" ); ! try { trans.Rollback(); rolledBack = true; ! } ! catch( Exception e ) { ! log.Error( "Rollback failed", e ); ! throw new TransactionException( "Rollback failed with SQL Exception", e ); ! } ! finally { session.AfterTransactionCompletion(); *************** *** 140,149 **** } ! public bool WasRolledBack { get { return rolledBack; } } ! public bool WasCommitted { get { return committed; } --- 152,163 ---- } ! /// <summary></summary> ! public bool WasRolledBack { get { return rolledBack; } } ! /// <summary></summary> ! public bool WasCommitted { get { return committed; } *************** *** 151,153 **** } ! } --- 165,167 ---- } ! } \ No newline at end of file Index: TransactionFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/TransactionFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TransactionFactory.cs 20 Feb 2003 15:57:13 -0000 1.1 --- TransactionFactory.cs 31 Dec 2004 22:41:39 -0000 1.2 *************** *** 1,21 **** - using System; - using System.Data; using System.Collections; using NHibernate.Engine; ! namespace NHibernate.Transaction { ! /// <summary> /// Summary description for TransactionFactory. /// </summary> ! public class TransactionFactory : ITransactionFactory { ! ! public ITransaction BeginTransaction(ISessionImplementor session) { ! Transaction tx = new Transaction(session); tx.Begin(); return tx; } ! public void Configure(IDictionary props) {} } ! } --- 1,31 ---- using System.Collections; using NHibernate.Engine; ! namespace NHibernate.Transaction ! { /// <summary> /// Summary description for TransactionFactory. /// </summary> ! public class TransactionFactory : ITransactionFactory ! { ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! public ITransaction BeginTransaction( ISessionImplementor session ) ! { ! Transaction tx = new Transaction( session ); tx.Begin(); return tx; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="props"></param> ! public void Configure( IDictionary props ) ! { ! } } ! } \ No newline at end of file |