You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by rg...@apache.org on 2005/12/17 23:19:47 UTC
svn commit: r357393 -
/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
Author: rgrabowski
Date: Sat Dec 17 14:19:29 2005
New Revision: 357393
URL: http://svn.apache.org/viewcvs?rev=357393&view=rev
Log:
Moved calls to GetMappedStatement inside try/catch block so connection will be closed if statementName is not a valid statement.
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=357393&r1=357392&r2=357393&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Sat Dec 17 14:19:29 2005
@@ -156,7 +156,7 @@
#region Methods
/// <summary>
- /// Set the falg to tell us if cache models were enabled
+ /// Set the flag to tell us if cache models were enabled
/// or not.
/// </summary>
internal void SetCacheModelsEnabled(bool value)
@@ -602,10 +602,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
result = statement.ExecuteQueryForObject(session, parameterObject);
}
catch
@@ -623,7 +622,6 @@
return result;
}
-
/// <summary>
/// Executes a Sql SELECT statement that returns a single object of the type of the
/// resultObject parameter.
@@ -645,10 +643,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
result = statement.ExecuteQueryForObject(session, parameterObject, resultObject);
}
catch
@@ -665,7 +662,6 @@
return result;
}
-
#endregion
@@ -712,7 +708,6 @@
return QueryForMap(statementName, parameterObject, keyProperty, null);
}
-
/// <summary>
/// Executes the SQL and retuns all rows selected in a map that is keyed on the property named
/// in the keyProperty parameter. The value at each key will be the value of the property specified
@@ -737,10 +732,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
map = statement.ExecuteQueryForMap(session, parameterObject, keyProperty, valueProperty);
}
catch
@@ -757,7 +751,6 @@
return map;
}
-
#endregion
@@ -786,10 +779,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
list = statement.ExecuteQueryForList(session, parameterObject);
}
catch
@@ -807,7 +799,6 @@
return list;
}
-
/// <summary>
/// Executes the SQL and retuns all rows selected.
/// <p/>
@@ -832,10 +823,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
list = statement.ExecuteQueryForList(session, parameterObject, skipResults, maxResults);
}
catch
@@ -882,10 +872,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
statement.ExecuteQueryForList(session, parameterObject, resultObject);
}
catch
@@ -901,7 +890,6 @@
}
}
-
#endregion
#region QueryForPaginatedList
@@ -946,10 +934,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
list = statement.ExecuteQueryForRowDelegate(session, parameterObject, rowDelegate);
}
catch
@@ -967,7 +954,6 @@
return list;
}
-
/// <summary>
/// Runs a query with a custom object that gets a chance to deal
/// with each row as it is processed.
@@ -995,10 +981,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
map = statement.ExecuteQueryForMapWithRowDelegate(session, parameterObject, keyProperty, valueProperty, rowDelegate);
}
catch
@@ -1015,7 +1000,6 @@
return map;
}
-
#endregion
@@ -1050,10 +1034,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
generatedKey = statement.ExecuteInsert(session, parameterObject);
}
catch
@@ -1071,7 +1054,6 @@
return generatedKey;
}
-
/// <summary>
/// Executes a Sql UPDATE statement.
/// Update can also be used for any other update statement type,
@@ -1084,9 +1066,6 @@
/// <param name="statementName">The name of the statement to execute.</param>
/// <param name="parameterObject">The parameter object.</param>
/// <returns>The number of rows effected.</returns>
-// /// <exception cref="IBatisNet.Common.Exceptions.DalConcurrentException">
-// /// If no rows are effected throw this exception.
-// /// </exception>
public int Update(string statementName, object parameterObject)
{
bool isSessionLocal = false;
@@ -1100,10 +1079,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
rows = statement.ExecuteUpdate(session, parameterObject);
}
catch
@@ -1118,17 +1096,9 @@
}
}
-// // check that statement affected a row
-// if( rows == 0 )
-// {
-// // throw concurrency error if no record was affected
-// throw new ConcurrentException();
-// }
-
return rows;
}
-
/// <summary>
/// Executes a Sql DELETE statement.
/// Delete returns the number of rows effected.
@@ -1149,10 +1119,9 @@
isSessionLocal = true;
}
- IMappedStatement statement = GetMappedStatement(statementName);
-
try
{
+ IMappedStatement statement = GetMappedStatement(statementName);
rows = statement.ExecuteUpdate(session, parameterObject);
}
catch
@@ -1170,7 +1139,6 @@
return rows;
}
-
#endregion
#region Get/Add ParemeterMap, ResultMap, MappedStatement, TypeAlias, DataSource, CacheModel
@@ -1211,7 +1179,6 @@
get { return _mappedStatements; }
}
-
/// <summary>
/// Get a ParameterMap by name
/// </summary>
@@ -1226,7 +1193,6 @@
return (ParameterMap) _parameterMaps[name];
}
-
/// <summary>
/// Adds a (named) ParameterMap.
/// </summary>
@@ -1240,7 +1206,6 @@
_parameterMaps.Add(parameterMap.Id, parameterMap);
}
-
/// <summary>
/// Gets a ResultMap by name
/// </summary>
@@ -1284,7 +1249,6 @@
get { return _resultMaps; }
}
-
/// <summary>
/// The DataSource
/// </summary>
@@ -1293,11 +1257,6 @@
get { return _dataSource; }
set { _dataSource = value; }
}
-
-
-
-
-
/// <summary>
/// Flushes all cached objects that belong to this SqlMap