Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Data/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23634/Support
Modified Files:
AdoTransactionObjectSupport.cs ConnectionUtils.cs
Log Message:
SPRNET-776 - Unit tests for AdoPlatformTransactionManager
update docs to reflect limitations of AdoPlatformTransactionManager for nested transactions.
code cleanup in AdoTemplate, ConnectionUtils
Index: AdoTransactionObjectSupport.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Data/Support/AdoTransactionObjectSupport.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** AdoTransactionObjectSupport.cs 29 Aug 2007 03:42:13 -0000 1.6
--- AdoTransactionObjectSupport.cs 28 Nov 2007 05:54:47 -0000 1.7
***************
*** 31,47 ****
namespace Spring.Data.Support
{
! /// <summary>
! /// Convenient base class for ADO.NET transaction aware objects.
! /// </summary>
! /// <remarks>
! /// Can contain a ConnectionHolder object.
! /// </remarks>
! /// <author>Mark Pollack (.NET)</author>
! /// <version>$Id$</version>
! public abstract class AdoTransactionObjectSupport : ISavepointManager, ISmartTransactionObject
! {
! #region Fields
! private ConnectionHolder connectionHolder;
private IsolationLevel previousIsolationLevel;
--- 31,47 ----
namespace Spring.Data.Support
{
! /// <summary>
! /// Convenient base class for ADO.NET transaction aware objects.
! /// </summary>
! /// <remarks>
! /// Can contain a ConnectionHolder object.
! /// </remarks>
! /// <author>Mark Pollack (.NET)</author>
! /// <version>$Id$</version>
! public abstract class AdoTransactionObjectSupport : ISavepointManager, ISmartTransactionObject
! {
! #region Fields
! private ConnectionHolder connectionHolder;
private IsolationLevel previousIsolationLevel;
***************
*** 49,65 ****
private bool savepointAllowed;
! #endregion
! #region Constants
! /// <summary>
! /// The shared log instance for this class (and derived classes).
! /// </summary>
! protected static readonly ILog log =
! LogManager.GetLogger(typeof (AdoTransactionObjectSupport));
! #endregion
- #region Properties
public ConnectionHolder ConnectionHolder
{
--- 49,66 ----
private bool savepointAllowed;
! #endregion
! #region Constants
! /// <summary>
! /// The shared log instance for this class (and derived classes).
! /// </summary>
! protected static readonly ILog log =
! LogManager.GetLogger(typeof (AdoTransactionObjectSupport));
! #endregion
!
! #region Properties
public ConnectionHolder ConnectionHolder
{
***************
*** 70,77 ****
public bool HasConnectionHolder
{
! get
! {
! return (connectionHolder != null);
! }
}
--- 71,75 ----
public bool HasConnectionHolder
{
! get { return (connectionHolder != null); }
}
***************
*** 95,169 ****
public abstract bool RollbackOnly { get; }
! #endregion
!
! /// <summary>
! /// Create a new savepoint.
! /// </summary>
! /// <param name="savepointName">
! /// The name of the savepoint to create.
! /// </param>
! /// <remarks>
! /// You can roll back to a specific savepoint
! /// via <see cref="Spring.Transaction.ISavepointManager.RollbackToSavepoint"/>,
! /// and explicitly release a savepoint that you don't need anymore via
! /// <see cref="Spring.Transaction.ISavepointManager.ReleaseSavepoint"/>.
! /// <p>
! /// Note that most transaction managers will automatically release
! /// savepoints at transaction completion.
! /// </p>
! /// </remarks>
! /// <exception cref="Spring.Transaction.TransactionException">
! /// If the savepoint could not be created,
! /// either because the backend does not support it or because the
! /// transaction is not in an appropriate state.
! /// </exception>
! /// <returns>
! /// A savepoint object, to be passed into
! /// <see cref="Spring.Transaction.ISavepointManager.RollbackToSavepoint"/>
! /// or <see cref="Spring.Transaction.ISavepointManager.ReleaseSavepoint"/>.
! /// </returns>
! public virtual void CreateSavepoint(string savepointName)
! {
! throw new NotImplementedException();
! }
!
! /// <summary>
! /// Roll back to the given savepoint.
! /// </summary>
! /// <remarks>
! /// The savepoint will be automatically released afterwards.
! /// </remarks>
! /// <param name="savepoint">The savepoint to roll back to.</param>
! /// <exception cref="Spring.Transaction.TransactionException">
! /// If the rollback failed.
! /// </exception>
! public virtual void RollbackToSavepoint(string savepoint)
! {
! throw new NotImplementedException();
! }
! /// <summary>
! /// Explicitly release the given savepoint.
! /// </summary>
! /// <remarks>
! /// <p>
! /// Note that most transaction managers will automatically release
! /// savepoints at transaction completion.
! /// </p>
! /// <p>
! /// Implementations should fail as silently as possible if
! /// proper resource cleanup will still happen at transaction completion.
! /// </p>
! /// </remarks>
! /// <param name="savepoint">The savepoint to release.</param>
! /// <exception cref="Spring.Transaction.TransactionException">
! /// If the release failed.
! /// </exception>
! public virtual void ReleaseSavepoint(string savepoint)
! {
! throw new NotImplementedException();
! }
! }
! }
--- 93,170 ----
public abstract bool RollbackOnly { get; }
! #endregion
! /// <summary>
! /// Create a new savepoint.
! /// </summary>
! /// <param name="savepointName">
! /// The name of the savepoint to create.
! /// </param>
! /// <remarks>
! /// You can roll back to a specific savepoint
! /// via <see cref="Spring.Transaction.ISavepointManager.RollbackToSavepoint"/>,
! /// and explicitly release a savepoint that you don't need anymore via
! /// <see cref="Spring.Transaction.ISavepointManager.ReleaseSavepoint"/>.
! /// <p>
! /// Note that most transaction managers will automatically release
! /// savepoints at transaction completion.
! /// </p>
! /// </remarks>
! /// <exception cref="Spring.Transaction.TransactionException">
! /// If the savepoint could not be created,
! /// either because the backend does not support it or because the
! /// transaction is not in an appropriate state.
! /// </exception>
! /// <returns>
! /// A savepoint object, to be passed into
! /// <see cref="Spring.Transaction.ISavepointManager.RollbackToSavepoint"/>
! /// or <see cref="Spring.Transaction.ISavepointManager.ReleaseSavepoint"/>.
! /// </returns>
! public virtual void CreateSavepoint(string savepointName)
! {
! throw new NestedTransactionNotSupportedException(
! "Cannot create a nested transaction because savepoints have not been implemented in the metadata for the DbProvider.");
! }
+ /// <summary>
+ /// Roll back to the given savepoint.
+ /// </summary>
+ /// <remarks>
+ /// The savepoint will be automatically released afterwards.
+ /// </remarks>
+ /// <param name="savepoint">The savepoint to roll back to.</param>
+ /// <exception cref="Spring.Transaction.TransactionException">
+ /// If the rollback failed.
+ /// </exception>
+ public virtual void RollbackToSavepoint(string savepoint)
+ {
+ throw new NestedTransactionNotSupportedException(
+ "Cannot rollback to a savepoint in a nested transaction because savepoints have not been implemented in the metadata for the DbProvider.");
+
+ }
! /// <summary>
! /// Explicitly release the given savepoint.
! /// </summary>
! /// <remarks>
! /// <p>
! /// Note that most transaction managers will automatically release
! /// savepoints at transaction completion.
! /// </p>
! /// <p>
! /// Implementations should fail as silently as possible if
! /// proper resource cleanup will still happen at transaction completion.
! /// </p>
! /// </remarks>
! /// <param name="savepoint">The savepoint to release.</param>
! /// <exception cref="Spring.Transaction.TransactionException">
! /// If the release failed.
! /// </exception>
! public virtual void ReleaseSavepoint(string savepoint)
! {
! throw new NestedTransactionNotSupportedException(
! "Cannot release a savepoint in a nested transaction because savepoints have not been implemented in the metadata for the DbProvider.");
!
! }
! }
! }
\ No newline at end of file
Index: ConnectionUtils.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Data/Support/ConnectionUtils.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ConnectionUtils.cs 24 Jul 2007 21:01:11 -0000 1.8
--- ConnectionUtils.cs 28 Nov 2007 05:54:47 -0000 1.9
***************
*** 145,151 ****
}
IDbConnection conn = provider.CreateConnection();
! conn.Open();
!
! if (TransactionSynchronizationManager.SynchronizationActive)
{
LOG.Debug("Registering transaction synchronization for IDbConnection");
--- 145,151 ----
}
IDbConnection conn = provider.CreateConnection();
! conn.Open();
!
! if (TransactionSynchronizationManager.SynchronizationActive)
{
LOG.Debug("Registering transaction synchronization for IDbConnection");
***************
*** 208,211 ****
--- 208,216 ----
}
+ /// <summary>
+ /// Applies the current transaction timeout, if any, to the given ADO.NET IDbCommand object.
+ /// </summary>
+ /// <param name="command">The command.</param>
+ /// <param name="dbProvider">The db provider.</param>
public static void ApplyTransactionTimeout(IDbCommand command, IDbProvider dbProvider)
{
***************
*** 213,216 ****
--- 218,228 ----
}
+ /// <summary>
+ /// Applies the specified timeout - overridden by the current transaction timeout, if any, to to the
+ /// given ADO.NET IDb command object.
+ /// </summary>
+ /// <param name="command">The command.</param>
+ /// <param name="dbProvider">The db provider the command was obtained from.</param>
+ /// <param name="timeout">The timeout to apply (or 0 for no timeout outside of a transaction.</param>
public static void ApplyTransactionTimeout(IDbCommand command, IDbProvider dbProvider, int timeout)
{
|