You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/04/18 21:12:32 UTC

svn commit: r161783 - incubator/ibatis/trunk/cs/mapper/IBatisNet.Common incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands

Author: gbayon
Date: Mon Apr 18 12:12:28 2005
New Revision: 161783

URL: http://svn.apache.org/viewcvs?view=rev&rev=161783
Log:
- Add logging as JIRA35

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/PreparedCommandFactory.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs Mon Apr 18 12:12:28 2005
@@ -72,6 +72,8 @@
 		[NonSerialized]
 		private string _name = string.Empty;
 		[NonSerialized]
+		private string _description = string.Empty;
+		[NonSerialized]
 		private bool _isDefault = false;
 		[NonSerialized]
 		private bool _isEnabled = true;
@@ -335,6 +337,16 @@
 			}
 		}
 
+		/// <summary>
+		/// Description.
+		/// </summary>
+		[XmlAttribute("description")]
+		public string Description
+		{
+			get { return _description; }
+			set { _description = value;}
+		}
+		
 		/// <summary>
 		/// Parameter prefix use in store procedure.
 		/// </summary>

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config Mon Apr 18 12:12:28 2005
@@ -58,6 +58,9 @@
 		<logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory">
 			<level value="DEBUG" />
 		</logger>
+		<logger name="IBatisNet.DataMapper.Commands.DefaultPreparedCommand">
+			<level value="DEBUG" />
+		</logger>		
 		<logger name="IBatisNet.DataMapper.LazyLoadList">
 			<level value="DEBUG" />
 		</logger>

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config Mon Apr 18 12:12:28 2005
@@ -4,7 +4,7 @@
 	<clear/>
 	<provider
 		name="sqlServer1.0"
-		description="Microsoft SQL Server 7.0/2000 provider in framework .NET V1.0"
+		description="Microsoft SQL Server 7.0/2000, provider V1.0.3300.0 in framework .NET V1.0"
 		enabled="false"
 		assemblyName="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
 		connectionClass="System.Data.SqlClient.SqlConnection" 
@@ -21,7 +21,7 @@
 		/>	
 	<provider
 		name="sqlServer1.1"
-		description="Microsoft SQL Server 7.0/2000 provider in framework .NET V1.1"
+		description="Microsoft SQL Server 7.0/2000, provider V1.0.5000.0 in framework .NET V1.1"
 		default="true"
 		assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
 		connectionClass="System.Data.SqlClient.SqlConnection"
@@ -38,7 +38,7 @@
 	/>		
 	<provider 
 		name="OleDb1.1" 
-		description="OleDb provider in framework .NET V1.1"
+		description="OleDb, provider V1.0.5000.0 in framework .NET V1.1"
 		enabled="true" 
 		assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
 		connectionClass="System.Data.OleDb.OleDbConnection" 
@@ -55,7 +55,7 @@
 	/>
 	<provider 
 		name="Odbc1.1" 
-		description="Odbc provider in framework .NET V1.1"
+		description="Odbc, provider V1.0.5000.0 in framework .NET V1.1"
 		enabled="true" 
 		assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
 		connectionClass="System.Data.Odbc.OdbcConnection" 
@@ -72,7 +72,7 @@
 	/>
 	<provider
 		name="oracle9.2"
-		description="Oracle provider V9.2"
+		description="Oracle, Oracle provider V9.2.0.401"
 		enabled="false"
 		assemblyName="Oracle.DataAccess, Version=9.2.0.401, Culture=neutral, PublicKeyToken=89b483f429c47342"
 		connectionClass="Oracle.DataAccess.Client.OracleConnection" 
@@ -89,7 +89,7 @@
 	/>
 	<provider
 		name="oracle10.1"
-		description="Oracle provider V10.1"
+		description="Oracle, oracle provider V10.1.0.301"
 		enabled="false"
 		assemblyName="Oracle.DataAccess, Version=10.1.0.301, Culture=neutral, PublicKeyToken=89b483f429c47342"
 		connectionClass="Oracle.DataAccess.Client.OracleConnection" 
@@ -106,7 +106,7 @@
 	/>	
 	<provider 
 		name="oracleClient1.0" 
-		description="MS Oracle provider V1.0.5"
+		description="Oracle, Microsoft provider V1.0.5000.0"
 		enabled="true" 
 		default="false"
 		assemblyName="System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
@@ -124,7 +124,7 @@
 	/>
 	<provider
 		name="ByteFx"
-		description="MySQL provider"
+		description="MySQL, ByteFx provider V0.7.6.15073"
 		enabled="false"
 		assemblyName="ByteFX.MySqlClient, Version=0.7.6.15073, Culture=neutral, PublicKeyToken=f2fef6fed1732fc1"
 		connectionClass="ByteFX.Data.MySqlClient.MySqlConnection" 
@@ -141,7 +141,7 @@
 	/>
 	<provider
 		name="MySql"
-		description="MySQL provider"
+		description="MySQL, MySQL provider V1.0.3.31712"
 		enabled="false"
 		assemblyName="MySql.Data, Version=1.0.3.31712, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
 		connectionClass="MySql.Data.MySqlClient.MySqlConnection" 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs Mon Apr 18 12:12:28 2005
@@ -24,9 +24,12 @@
  ********************************************************************************/
 #endregion
 
-#region Imports
+#region Using
 using System.Data;
 using System.Collections;
+using System.Text;
+
+using log4net;
 
 using IBatisNet.Common;
 using IBatisNet.Common.Utilities.Objects;
@@ -42,8 +45,13 @@
 	/// <summary>
 	/// Summary description for DefaultPreparedCommand.
 	/// </summary>
-	public class DefaultPreparedCommand : IPreparedCommand
+	internal class DefaultPreparedCommand : IPreparedCommand
 	{
+
+		#region Fields
+		private static readonly ILog _logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
+		#endregion 
+
 		#region IPreparedCommand Members
 
 		/// <summary>
@@ -61,14 +69,20 @@
 		{
 			// the IDbConnection & the IDbTransaction are assign in the CreateCommand 
 			IDbCommand command = session.CreateCommand(statement.CommandType);
-				
+			
+			if (_logger.IsDebugEnabled)
+			{
+				_logger.Debug("PreparedStatement : [" + request.PreparedStatement.PreparedSql + "]");
+			}
+
 			command.CommandText = request.PreparedStatement.PreparedSql;
 
-			ApplyParameterMap( session, command, request, statement, parameterObject );
+			ApplyParameterMap( session, command, request, statement, parameterObject  );
 
 			return command;
 		}
 
+
 		/// <summary>
 		/// 
 		/// </summary>
@@ -83,6 +97,9 @@
 		{
 			ArrayList properties = request.PreparedStatement.DbParametersName;
 			ArrayList parameters = request.PreparedStatement.DbParameters;
+			StringBuilder valueList = new StringBuilder(); // Log info
+			StringBuilder typeList = new StringBuilder(); // Log info 
+
 			object parameterValue = null;
 
 			for ( int i = 0; i < properties.Count; ++i )
@@ -131,6 +148,22 @@
 					}
 				}
 
+				#region Logging
+
+				if (parameterValue == System.DBNull.Value) 
+				{
+					valueList.Append("null,");
+					typeList.Append("null,");
+				} 
+				else 
+				{
+					valueList.Append( parameterValue.ToString() );
+					valueList.Append( "," );
+					typeList.Append( parameterValue.GetType().ToString() );
+					typeList.Append( "," );
+				}
+				#endregion 
+
 				IDataParameter parameterCopy = command.CreateParameter();
 				// Fix JIRA 20
 				sqlParameter.Value = parameterValue;
@@ -164,6 +197,12 @@
 				parameterCopy.ParameterName = sqlParameter.ParameterName;
 
 				command.Parameters.Add( parameterCopy );
+			}
+
+			if (_logger.IsDebugEnabled && properties.Count>0)
+			{
+				_logger.Debug("Parameters: [" + valueList.ToString().Remove(valueList.ToString().Length-1,1) + "]");
+				_logger.Debug("Types: [" + typeList.ToString().Remove(typeList.ToString().Length-1,1) + "]");
 			}
 		}
 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs Mon Apr 18 12:12:28 2005
@@ -44,7 +44,7 @@
 	/// <summary>
 	/// Summary description for EmbedParamsPreparedCommand.
 	/// </summary>
-	public class EmbedParamsPreparedCommand : DefaultPreparedCommand
+	internal class EmbedParamsPreparedCommand : DefaultPreparedCommand
 	{
 		#region EmbedParamsPreparedCommand Members
 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/PreparedCommandFactory.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/PreparedCommandFactory.cs?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/PreparedCommandFactory.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/PreparedCommandFactory.cs Mon Apr 18 12:12:28 2005
@@ -32,7 +32,7 @@
 	/// <summary>
 	/// Summary description for PreparedCommandFactory.
 	/// </summary>
-	public class PreparedCommandFactory
+	internal class PreparedCommandFactory
 	{
 		/// <summary>
 		/// Get an IPreparedCommand.

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs?view=diff&r1=161782&r2=161783
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs Mon Apr 18 12:12:28 2005
@@ -154,12 +154,12 @@
 					_connection.Open();
 					if (_logger.IsDebugEnabled)
 					{
-						_logger.Debug("Open Connection");
+						_logger.Debug( string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
 					}
 				}
 				catch(Exception ex)
 				{
-					throw new DataMapperException( "Unable to open connection.", ex );
+					throw new DataMapperException( string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
 				}
 			}
 			else if (_connection.State != ConnectionState.Open)
@@ -169,12 +169,12 @@
 					_connection.Open();
 					if (_logger.IsDebugEnabled)
 					{
-						_logger.Debug("Open Connection");
+						_logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
 					}
 				}
 				catch(Exception ex)
 				{
-					throw new DataMapperException("Unable to open connection.", ex );
+					throw new DataMapperException(string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
 				}
 			}
 		}
@@ -186,11 +186,12 @@
 		{
 			if ( (_connection != null) && (_connection.State != ConnectionState.Closed) )
 			{
+				_connection.Close();
 				if (_logger.IsDebugEnabled)
 				{
-					_logger.Debug("Close Connection");
+
+					_logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description));
 				}
-				_connection.Close();
 				_connection.Dispose();
 			}
 			_connection = null;
@@ -208,7 +209,7 @@
 			_transaction = _connection.BeginTransaction();
 			if (_logger.IsDebugEnabled)
 			{
-				_logger.Debug("Begin Transaction");
+				_logger.Debug("Begin Transaction.");
 			}
 			_isOpenTransaction = true;
 		}
@@ -232,7 +233,7 @@
 				_transaction = _connection.BeginTransaction();
 				if (_logger.IsDebugEnabled)
 				{
-					_logger.Debug("Begin Transaction");
+					_logger.Debug("Begin Transaction.");
 				}
 				_isOpenTransaction = true;
 			}
@@ -253,7 +254,7 @@
 			_transaction = _connection.BeginTransaction(isolationLevel);
 			if (_logger.IsDebugEnabled)
 			{
-				_logger.Debug("Begin Transaction");
+				_logger.Debug("Begin Transaction.");
 			}
 			_isOpenTransaction = true;
 		}
@@ -279,7 +280,7 @@
 				_transaction = _connection.BeginTransaction(isolationLevel);
 				if (_logger.IsDebugEnabled)
 				{
-					_logger.Debug("Start Transaction");
+					_logger.Debug("Begin Transaction.");
 				}
 				_isOpenTransaction = true;
 			}
@@ -296,7 +297,7 @@
 		{
 			if (_logger.IsDebugEnabled)
 			{
-				_logger.Debug("Commit Transaction");
+				_logger.Debug("Commit Transaction.");
 			}
 			_transaction.Commit();
 			_transaction.Dispose();
@@ -318,11 +319,11 @@
 			}
 			else
 			{
+				_transaction.Commit();
 				if (_logger.IsDebugEnabled)
 				{
-					_logger.Debug("Commit Transaction");
+					_logger.Debug("Commit Transaction.");
 				}
-				_transaction.Commit();
 				_transaction.Dispose();
 			}
 		}
@@ -335,11 +336,11 @@
 		/// </remarks>
 		public void RollBackTransaction()
 		{
+			_transaction.Rollback();
 			if (_logger.IsDebugEnabled)
 			{
-				_logger.Debug("RollBack Transaction");
+				_logger.Debug("RollBack Transaction.");
 			}
-			_transaction.Rollback();
 			_transaction.Dispose();
 			_transaction = null;
 			if (_connection.State != ConnectionState.Closed)
@@ -362,7 +363,7 @@
 			{
 				if (_logger.IsDebugEnabled)
 				{
-					_logger.Debug("RollBack Transaction");
+					_logger.Debug("RollBack Transaction.");
 				}
 				_transaction.Rollback();
 				_transaction.Dispose();