You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by ro...@apache.org on 2005/03/30 06:28:37 UTC

svn commit: r159463 - in incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper: ./ Configuration/ MappedStatements/ Scope/ Test/ Test/bin/Debug/

Author: roberto
Date: Tue Mar 29 20:28:35 2005
New Revision: 159463

URL: http://svn.apache.org/viewcvs?view=rev&rev=159463
Log:
~ Updating C# DataMapper core and NUnit tests for new embedStatementParams flag

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj Tue Mar 29 20:28:35 2005
@@ -249,6 +249,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Domain\Sample.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Domain\Search.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -399,6 +404,10 @@
                     BuildAction = "Content"
                 />
                 <File
+                    RelPath = "Maps\MSSQL\SqlClient\EmbedParameter.xml"
+                    BuildAction = "Content"
+                />
+                <File
                     RelPath = "Maps\MSSQL\SqlClient\Enumeration.xml"
                     BuildAction = "Content"
                 />
@@ -604,6 +613,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "NUnit\SqlMapTests\MSSQL\EmbedParameterTest.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "NUnit\SqlMapTests\MSSQL\ProcedureTest.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -728,6 +742,14 @@
                     BuildAction = "Content"
                 />
                 <File
+                    RelPath = "Scripts\MSSQL\embed-param-setup-init.sql"
+                    BuildAction = "Content"
+                />
+                <File
+                    RelPath = "Scripts\MSSQL\embed-param-test-init.sql"
+                    BuildAction = "Content"
+                />
+                <File
                     RelPath = "Scripts\MSSQL\enumeration-init.sql"
                     BuildAction = "Content"
                 />
@@ -745,6 +767,10 @@
                 />
                 <File
                     RelPath = "Scripts\MSSQL\other-init.sql"
+                    BuildAction = "Content"
+                />
+                <File
+                    RelPath = "Scripts\MSSQL\README-embed-param.txt"
                     BuildAction = "Content"
                 />
                 <File

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Tue Mar 29 20:28:35 2005
@@ -3,6 +3,7 @@
 	<settings>
 		<setting useStatementNamespaces="false"/>
 		<setting cacheModelsEnabled="true"/>
+		<setting embedStatementParams="false"/>
 	</settings>
 
 	<!-- Rem : If used via a DataAccess context, properties tag will be ignored -->
@@ -31,6 +32,7 @@
 		<sqlMap resource="../../Maps/MSSQL/SqlClient/Other.xml"/>
 		<sqlMap resource="../../Maps/MSSQL/SqlClient/ResultClass.xml"/>
 		<sqlMap resource="../../Maps/MSSQL/SqlClient/Document.xml"/>
+		<sqlMap resource="../../Maps/MSSQL/SqlClient/EmbedParameter.xml"/>
 		<!-- Rem : If used as embbeded Resources, use
 		<sqlMap embedded="Account.xml, IBatisNet.Test"/>
 		-->

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Tue Mar 29 20:28:35 2005
@@ -109,6 +109,10 @@
 		/// Token for cacheModelsEnabled attribute.
 		/// </summary>
 		private const string ATR_CACHE_MODELS_ENABLED = "cacheModelsEnabled";
+		/// <summary>
+		/// Token for embedStatementParams attribute.
+		/// </summary>
+		private const string ATR_EMBED_STATEMENT_PARAMS = "embedStatementParams";
 
 		#endregion
 
@@ -258,10 +262,15 @@
 					{				
 						_configScope.IsCacheModelsEnabled =  System.Convert.ToBoolean(setting.Attributes[ATR_CACHE_MODELS_ENABLED].Value); 
 					}
+					if (setting.Attributes[ATR_EMBED_STATEMENT_PARAMS] != null )
+					{				
+						_configScope.IsEmbedStatementParams =  System.Convert.ToBoolean(setting.Attributes[ATR_EMBED_STATEMENT_PARAMS].Value); 
+					}
 				}
 			}
 
 			_configScope.SqlMapper.SetCacheModelsEnabled(_configScope.IsCacheModelsEnabled);
+			_configScope.SqlMapper.SetEmbedStatementParams(_configScope.IsEmbedStatementParams);
 
 			#endregion
 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Tue Mar 29 20:28:35 2005
@@ -176,6 +176,26 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Commands\DefaultPreparedCommand.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Commands\EmbedParamsPreparedCommand.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Commands\IPreparedCommand.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Commands\PreparedCommandFactory.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Configuration\DomSqlMapBuilder.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Tue Mar 29 20:28:35 2005
@@ -36,6 +36,7 @@
 using IBatisNet.Common.Utilities.Objects;
 
 using IBatisNet.DataMapper;
+using IBatisNet.DataMapper.Commands;
 using IBatisNet.DataMapper.Configuration;
 using IBatisNet.DataMapper.Configuration.Statements;
 using IBatisNet.DataMapper.Configuration.ResultMapping;
@@ -553,7 +554,9 @@
 		{
 			object result = resultObject;
 			
-			using ( IDbCommand command = CreatePreparedCommand( request, session, parameterObject ) )
+			//using ( IDbCommand command = CreatePreparedCommand( request, session, parameterObject ) )
+			IPreparedCommand preparedCommand = PreparedCommandFactory.GetPreparedCommand(SqlMap.IsEmbedStatementParams);
+			using ( IDbCommand command = preparedCommand.Create( request, session, this.Statement, parameterObject ) )
 			{
 				using ( IDataReader reader = command.ExecuteReader() )
 				{				
@@ -680,7 +683,9 @@
 		{
 			IList list = null;
 			
-			using ( IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			//using ( IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			IPreparedCommand preparedCommand = PreparedCommandFactory.GetPreparedCommand(SqlMap.IsEmbedStatementParams);
+			using ( IDbCommand command = preparedCommand.Create( request, session, this.Statement, parameterObject ) )
 			{
 				if (_statement.ListClass == null)
 				{
@@ -748,7 +753,9 @@
 			IList result = new ArrayList();
 			RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
 
-			using ( IDbCommand command = CreatePreparedCommand(request, session, parameterObject ) )
+			//using ( IDbCommand command = CreatePreparedCommand(request, session, parameterObject ) )
+			IPreparedCommand preparedCommand = PreparedCommandFactory.GetPreparedCommand(SqlMap.IsEmbedStatementParams);
+			using ( IDbCommand command = preparedCommand.Create( request, session, this.Statement, parameterObject ) )
 			{
 				using ( IDataReader reader = command.ExecuteReader() )
 				{			
@@ -783,7 +790,10 @@
 			int rows = 0; // the number of rows affected
 			RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
 
-			using (IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			//using (IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			IPreparedCommand preparedCommand = PreparedCommandFactory.GetPreparedCommand(SqlMap.IsEmbedStatementParams);
+			
+			using ( IDbCommand command = preparedCommand.Create( request, session, this.Statement, parameterObject ) )
 			{
 				rows = command.ExecuteNonQuery();
 
@@ -824,7 +834,9 @@
 				ObjectProbe.SetPropertyValue(parameterObject, selectKeyStatement.PropertyName, generatedKey);
 			}
 
-			using (IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			//using (IDbCommand command = CreatePreparedCommand(request, session, parameterObject ))
+			IPreparedCommand preparedCommand = PreparedCommandFactory.GetPreparedCommand(SqlMap.IsEmbedStatementParams);
+			using ( IDbCommand command = preparedCommand.Create( request, session, this.Statement, parameterObject ) )
 			{
 				if (_statement is Insert)
 				{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Tue Mar 29 20:28:35 2005
@@ -56,6 +56,7 @@
 		private bool _useConfigFileWatcher = false;
 		private bool _useStatementNamespaces = false;
 		private bool _isCacheModelsEnabled = false;
+		private bool _isEmbedStatementParams = false;
 		private bool _isCallFromDao = false;
 
 		private SqlMapper _sqlMapper = null;
@@ -277,6 +278,21 @@
 			get
 			{
 				return _properties;
+			}
+		}
+
+		/// <summary>
+		/// Indicates if parameters should be embedded in the sql statement.
+		/// </summary>
+		public bool IsEmbedStatementParams
+		{
+			get
+			{
+				return _isEmbedStatementParams;
+			}
+			set
+			{
+				_isEmbedStatementParams = value;
 			}
 		}
 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd Tue Mar 29 20:28:35 2005
@@ -37,6 +37,7 @@
 		<xs:complexType>
 			<xs:attribute name="useStatementNamespaces" type="xs:boolean"/>
 			<xs:attribute name="cacheModelsEnabled" type="xs:boolean"/>
+			<xs:attribute name="embedStatementParams" type="xs:boolean"/>
 		</xs:complexType>
 	</xs:element>
 	<xs:element name="settings">

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?view=diff&r1=159462&r2=159463
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Tue Mar 29 20:28:35 2005
@@ -81,6 +81,7 @@
 		private HybridDictionary _cacheMaps = new HybridDictionary();
 
 		private bool _cacheModelsEnabled = false;
+		private bool _embedStatementParams = false;
 
 		/// <summary>
 		/// Container session unique for each thread. 
@@ -118,6 +119,15 @@
 		{
 			get { return _cacheModelsEnabled; }
 		}
+
+		/// <summary>
+		/// A flag that determines whether statements should have
+		/// embedded parameters.
+		/// </summary>
+		public bool IsEmbedStatementParams
+		{
+			get { return _embedStatementParams; }
+		}
 		#endregion
 
 		#region Constructor (s) / Destructor
@@ -138,6 +148,15 @@
 		internal void SetCacheModelsEnabled(bool value)
 		{
 			_cacheModelsEnabled = value;
+		}
+
+		/// <summary>
+		/// Sets the flag indicating if statements should have embedded
+		/// parameters
+		/// </summary>
+		internal void SetEmbedStatementParams(bool value)
+		{
+			_embedStatementParams = value;
 		}
 
 		#region Configure