Author: gbayon
Date: Sun Sep 21 09:29:40 2008
New Revision: 697537
URL: http://svn.apache.org/viewvc?rev=697537&view=rev
Log:
fix IBATISNET-282
Added:
ibatis/trunk/cs/V3/src/AssemblyKey.snk (with props)
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSource.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSourceDeSerializer.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/IDataSource.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/ModuleConfigurationTest.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationStore.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildDataSource.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/LoadSetting.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Data/DefaultPreparedCommand.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMapConfig.xsd
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSource.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSource.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSource.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSource.cs Sun Sep 21
09:29:40 2008
@@ -27,7 +27,6 @@
#region Using
using System;
-using System.Xml.Serialization;
using Apache.Ibatis.Common.Contracts;
using System.Diagnostics;
@@ -42,15 +41,13 @@
[DebuggerDisplay("DataSource: {Id}-{ConnectionString}")]
public class DataSource : IDataSource
{
-
- #region Fields
[NonSerialized]
private string connectionString = string.Empty;
[NonSerialized]
private IDbProvider provider = null;
[NonSerialized]
- private string id = string.Empty;
- #endregion
+ private readonly string id = string.Empty;
+ private readonly int commandTimeout;
#region Properties
@@ -72,6 +69,14 @@
get { return id; }
}
+ /// <summary>
+ /// Gets the command timeout.
+ /// </summary>
+ /// <value>The command timeout.</value>
+ public int CommandTimeout
+ {
+ get { return commandTimeout; }
+ }
/// <summary>
/// Gets or sets the db provider.
@@ -81,7 +86,6 @@
{
get { return provider; }
set { provider = value; }
-
}
#endregion
@@ -90,8 +94,9 @@
/// </summary>
/// <param name="id">The id.</param>
/// <param name="connectionString">The connection string.</param>
+ /// <param name="commandTimeout">The command timeout.</param>
/// <param name="provider">The provider.</param>
- public DataSource(string id, string connectionString, IDbProvider
provider)
+ public DataSource(string id, string connectionString, int
commandTimeout, IDbProvider provider)
{
Contract.Require.That(connectionString, Is.Not.Null &
Is.Not.Empty).When("retrieving argument connectionString in DataSource
constructor");
Contract.Require.That(provider, Is.Not.Null).When("retrieving
argument provider in DataSource constructor");
@@ -99,6 +104,7 @@
this.id = id;
this.connectionString = connectionString;
this.provider = provider;
+ this.commandTimeout = commandTimeout;
}
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSourceDeSerializer.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSourceDeSerializer.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSourceDeSerializer.cs
(original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/DataSourceDeSerializer.cs
Sun Sep 21 09:29:40 2008
@@ -41,16 +41,18 @@
/// <summary>
/// Deserialize a DataSource object
/// </summary>
+ /// <param name="dbProvider">The db provider.</param>
+ /// <param name="commandTimeOut">The command time out.</param>
/// <param name="config">The config.</param>
/// <returns></returns>
- public static DataSource Deserialize(IDbProvider
dbProvider,IConfiguration config)
+ public static DataSource Deserialize(IDbProvider dbProvider, int
commandTimeOut, IConfiguration config)
{
IConfiguration dataSourceConfig =
config.Children.Find(DataConstants.ELEMENT_DATASOURCE)[0];
string connectionString =
dataSourceConfig.Attributes[DataConstants.ATTRIBUTE_CONNECTIONSTRING];
string name =
dataSourceConfig.Attributes[DataConstants.ATTRIBUTE_NAME];
- return new DataSource(name, connectionString, dbProvider);
+ return new DataSource(name, connectionString, commandTimeOut,
dbProvider);
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/IDataSource.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/IDataSource.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/IDataSource.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Data/IDataSource.cs Sun Sep 21
09:29:40 2008
@@ -35,6 +35,11 @@
/// </summary>
string Id { get; }
+ /// <summary>
+ /// Gets the command timeout.
+ /// </summary>
+ /// <value>The command timeout.</value>
+ int CommandTimeout { get; }
/// <summary>
/// Gets or sets the connection string.
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/ModuleConfigurationTest.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/ModuleConfigurationTest.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/ModuleConfigurationTest.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/ModuleConfigurationTest.cs
Sun Sep 21 09:29:40 2008
@@ -66,6 +66,11 @@
set { throw new Exception("The method or operation is not
implemented."); }
}
+ public int CommandTimeout
+ {
+ get { throw new Exception("The method or operation is not
implemented."); }
+ }
+
#endregion
}
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
Sun Sep 21 09:29:40 2008
@@ -73,6 +73,8 @@
private bool useStatementNamespaces = false;
private bool isCacheModelsEnabled = false;
private bool useReflectionOptimizer = true;
+ private int commandTimeOut = -1;
+
private readonly WaitResultPropertyResolution
waitResultPropertyResolution = null;
private readonly WaitDiscriminatorResolution
waitDiscriminatorResolution = null;
private ISqlSource dynamicSqlEngine = null;
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationStore.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationStore.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationStore.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationStore.cs
Sun Sep 21 09:29:40 2008
@@ -171,21 +171,6 @@
/// <returns></returns>
IConfiguration[] Alias { get; }
- ///// <summary>
- ///// Returns the configuration node associated with
- ///// the specified SqlMapping key. Should return null
- ///// if no association exists.
- ///// </summary>
- ///// <param name="key">item key</param>
- ///// <returns></returns>
- //IConfiguration GetSqlMappingConfiguration(string key);
-
- ///// <summary>
- ///// Returns all configuration nodes for SqlMapping
- ///// </summary>
- ///// <returns></returns>
- //IConfiguration[] SqlMappings { get; }
-
#endregion
#region IMappingConfigurationStore
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
Sun Sep 21 09:29:40 2008
@@ -256,6 +256,10 @@
/// </summary>
public const string ATTRIBUTE_VALIDATE_SQLMAP = "validateSqlMap";
/// <summary>
+ /// Token for attribute command.timeout.
+ /// </summary>
+ public const string ATTRIBUTE_COMMAND_TIMEOUT = "commandTimeout";
+ /// <summary>
/// Token for attribute flushInterval.
/// </summary>
public const string ATTRIBUTE_FLUSHINTERVAL = "flushInterval";
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildDataSource.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildDataSource.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildDataSource.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildDataSource.cs
Sun Sep 21 09:29:40 2008
@@ -44,10 +44,7 @@
IConfiguration providerConfig =
dataBaseConfig.Children.Find(DataConstants.ELEMENT_PROVIDER)[0];
IDbProvider dbProvider =
dbProviderFactory.GetDbProvider(providerConfig.Value);
- //_configScope.ErrorContext.Resource =
nodeDataSource.OuterXml.ToString();
- //_configScope.ErrorContext.MoreInfo = "parse DataSource";
-
- dataSource = DataSourceDeSerializer.Deserialize(dbProvider,
dataBaseConfig);
+ dataSource = DataSourceDeSerializer.Deserialize(dbProvider,
commandTimeOut, dataBaseConfig);
}
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/LoadSetting.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/LoadSetting.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/LoadSetting.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/LoadSetting.cs
Sun Sep 21 09:29:40 2008
@@ -48,14 +48,18 @@
{
useStatementNamespaces =
Convert.ToBoolean(setting.Value);
}
- if (setting.Id ==
ConfigConstants.ATTRIBUTE_CACHE_MODELS_ENABLED)
+ else if (setting.Id ==
ConfigConstants.ATTRIBUTE_CACHE_MODELS_ENABLED)
{
isCacheModelsEnabled =
Convert.ToBoolean(setting.Value);
}
- if (setting.Id ==
ConfigConstants.ATTRIBUTE_USE_REFLECTION_OPTIMIZER)
+ else if (setting.Id ==
ConfigConstants.ATTRIBUTE_USE_REFLECTION_OPTIMIZER)
{
useReflectionOptimizer =
Convert.ToBoolean(setting.Value);
}
+ else if (setting.Id ==
ConfigConstants.ATTRIBUTE_COMMAND_TIMEOUT)
+ {
+ commandTimeOut = Convert.ToInt32(setting.Value);
+ }
}
}
}
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Data/DefaultPreparedCommand.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Data/DefaultPreparedCommand.cs?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
---
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Data/DefaultPreparedCommand.cs
(original)
+++
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Data/DefaultPreparedCommand.cs
Sun Sep 21 09:29:40 2008
@@ -89,28 +89,37 @@
command.CommandType = commandType;
command.Connection = session.Connection;
+ SetCommandTimeout(command,
session.SessionFactory.DataSource.CommandTimeout);
// Assign transaction
if (session.Transaction != null)
{
session.Transaction.Enlist(command);
}
- // Assign connection timeout
- if (session.Connection != null)
+ return command;
+ }
+
+ /// <summary>
+ /// Sets the command timeout.
+ /// </summary>
+ /// <param name="cmd">The CMD.</param>
+ /// <param name="commandTimeout">The command timeout.</param>
+ private void SetCommandTimeout(IDbCommand cmd, int commandTimeout)
+ {
+ if (commandTimeout >= 0)
{
- try // MySql provider doesn't suppport it !
+ try
{
- command.CommandTimeout =
session.Connection.ConnectionTimeout;
+ cmd.CommandTimeout = commandTimeout;
}
- catch (NotSupportedException e)
+ catch (Exception e)
{
- if (logger.IsInfoEnabled)
+ if (logger.IsWarnEnabled)
{
- logger.Info(e.Message);
+ logger.Warn(e.ToString());
}
}
}
- return command;
}
/// <summary>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMapConfig.xsd
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMapConfig.xsd?rev=697537&r1=697536&r2=697537&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMapConfig.xsd (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMapConfig.xsd Sun Sep 21
09:29:40 2008
@@ -85,6 +85,7 @@
<xs:attribute name="validateSqlMap" type="xs:string"
default="false"/>
<xs:attribute name="useEmbedStatementParams"
type="xs:boolean" default="false"/>
<xs:attribute name="useReflectionOptimizer"
type="xs:boolean" default="true"/>
+ <xs:attribute name="commandTimeout"
type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
<xs:element name="settings">
Added: ibatis/trunk/cs/V3/src/AssemblyKey.snk
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/AssemblyKey.snk?rev=697537&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/cs/V3/src/AssemblyKey.snk
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream