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 2008/06/08 20:20:46 UTC
svn commit: r664536 [2/4] - in /ibatis/trunk/cs/V3/src:
Apache.Ibatis.DataMapper.SqlClient.Test.2005/
Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/
Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/
Apache.Ibatis.DataMapper.SqlClie...
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapper.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapper.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapper.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapper.cs Sun Jun 8 11:20:44 2008
@@ -24,7 +24,6 @@
********************************************************************************/
#endregion
-using System;
using System.Collections;
using System.Collections.Generic;
@@ -133,7 +132,7 @@
{
if (resultObject == null)
{
- throw new DataMapperException("resultObject parameter must be instantiated before being passed to SqlMapper.QueryForList");
+ throw new DataMapperException("resultObject parameter must be instantiated before being passed to QueryForList");
}
using (DataMapperLocalSessionScope sessionScope = new DataMapperLocalSessionScope(sessionStore, sessionFactory))
@@ -258,11 +257,7 @@
/// </returns>
public object QueryForObject(string statementId, object parameterObject)
{
- using (DataMapperLocalSessionScope sessionScope = new DataMapperLocalSessionScope(sessionStore, sessionFactory))
- {
- IMappedStatement statement = modelStore.GetMappedStatement(statementId);
- return statement.ExecuteQueryForObject(sessionScope.Session, parameterObject);
- }
+ return QueryForObject(statementId, parameterObject, null);
}
/// <summary>
@@ -409,11 +404,7 @@
/// </returns>
public T QueryForObject<T>(string statementId, object parameterObject)
{
- using (DataMapperLocalSessionScope sessionScope = new DataMapperLocalSessionScope(sessionStore, sessionFactory))
- {
- IMappedStatement statement = modelStore.GetMappedStatement(statementId);
- return statement.ExecuteQueryForObject<T>(sessionScope.Session, parameterObject);
- }
+ return QueryForObject<T>(statementId, parameterObject, default(T));
}
/// <summary>
@@ -492,11 +483,7 @@
/// <returns>The number of rows effected.</returns>
public int Delete(string statementId, object parameterObject)
{
- using (DataMapperLocalSessionScope sessionScope = new DataMapperLocalSessionScope(sessionStore, sessionFactory))
- {
- IMappedStatement statement = modelStore.GetMappedStatement(statementId);
- return statement.ExecuteUpdate(sessionScope.Session, parameterObject);
- }
+ return Update(statementId, parameterObject);
}
#endregion
@@ -514,50 +501,5 @@
#endregion
- /// <summary>
- /// Local SessionScope management
- /// </summary>
- private class DataMapperLocalSessionScope : IDisposable
- {
- private readonly bool isSessionLocal = false;
- private readonly ISession session = null;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="DataMapperLocalSessionScope"/> class.
- /// </summary>
- /// <param name="sessionStore">The session store.</param>
- /// <param name="sessionFactory">The session factory.</param>
- public DataMapperLocalSessionScope(ISessionStore sessionStore, ISessionFactory sessionFactory)
- {
- isSessionLocal = false;
- session = sessionStore.CurrentSession;
-
- if (session == null)
- {
- session = sessionFactory.OpenSession();
- isSessionLocal = true;
- }
- }
-
- /// <summary>
- /// Gets the session.
- /// </summary>
- /// <value>The session.</value>
- public ISession Session
- {
- get { return session; }
- }
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- public void Dispose()
- {
- if (isSessionLocal)
- {
- session.Close();
- }
- }
- }
}
}
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs?rev=664536&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs Sun Jun 8 11:20:44 2008
@@ -0,0 +1,77 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 513043 $
+ * $Date$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using Apache.Ibatis.DataMapper.Session;
+
+namespace Apache.Ibatis.DataMapper
+{
+ /// <summary>
+ /// Local SessionScope management
+ /// </summary>
+ public class DataMapperLocalSessionScope : IDisposable
+ {
+ private readonly bool isSessionLocal = false;
+ private readonly ISession session = null;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DataMapperLocalSessionScope"/> class.
+ /// </summary>
+ /// <param name="sessionStore">The session store.</param>
+ /// <param name="sessionFactory">The session factory.</param>
+ public DataMapperLocalSessionScope(ISessionStore sessionStore, ISessionFactory sessionFactory)
+ {
+ isSessionLocal = false;
+ session = sessionStore.CurrentSession;
+
+ if (session == null)
+ {
+ session = sessionFactory.OpenSession();
+ isSessionLocal = true;
+ }
+ }
+
+ /// <summary>
+ /// Gets the session.
+ /// </summary>
+ /// <value>The session.</value>
+ public ISession Session
+ {
+ get { return session; }
+ }
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ if (isSessionLocal)
+ {
+ session.Close();
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/DataMapperLocalSessionScope.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/ResultMapStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/ResultMapStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/ResultMapStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/ResultMapStrategy.cs Sun Jun 8 11:20:44 2008
@@ -60,7 +60,7 @@
for (int index = 0; index < resultMapping.Parameters.Count; index++)
{
ResultProperty property = resultMapping.Parameters[index];
- parameters[index] = property.ArgumentStrategy.GetValue(request, property, ref reader, null);
+ parameters[index] = property.GetValue(request, ref reader, null);
request.IsRowDataFound = request.IsRowDataFound || (parameters[index] != null);
isParameterFound = isParameterFound || (parameters[index] != null);
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/SelectObjectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/SelectObjectStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/SelectObjectStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/ArgumentStrategy/SelectObjectStrategy.cs Sun Jun 8 11:20:44 2008
@@ -56,7 +56,7 @@
IMappedStatement selectStatement = request.MappedStatement.ModelStore.GetMappedStatement(mapping.Select);
reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);
- return selectStatement.ExecuteQueryForObject(request.Session, keys);
+ return selectStatement.ExecuteQueryForObject(request.Session, keys, null);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs Sun Jun 8 11:20:44 2008
@@ -28,9 +28,12 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.Diagnostics;
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Model.Cache;
+using Apache.Ibatis.DataMapper.Model.Events;
+using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Scope;
using Apache.Ibatis.DataMapper.Session;
@@ -40,11 +43,12 @@
namespace Apache.Ibatis.DataMapper.MappedStatements
{
/// <summary>
- /// Summary description for CachingStatement.
+ /// Acts as a decorator arounf an <see cref="IMappedStatement"/> to add cache functionality
/// </summary>
+ [DebuggerDisplay("MappedStatement: {mappedStatement.Id}")]
public sealed class CachingStatement : IMappedStatement
{
- private MappedStatement _mappedStatement =null;
+ private MappedStatement mappedStatement =null;
/// <summary>
/// Event launch on exceute query
@@ -57,18 +61,78 @@
/// <param name="statement"></param>
public CachingStatement(MappedStatement statement)
{
- _mappedStatement = statement;
+ mappedStatement = statement;
}
#region IMappedStatement Members
+ /// <summary>
+ /// Gets or sets the pre insert listener.
+ /// </summary>
+ /// <value>The pre insert listener.</value>
+ public IStatementEventListener<PreInsertEvent>[] PreInsertListeners
+ {
+ get { return mappedStatement.PreInsertListeners; }
+ set { mappedStatement.PreInsertListeners = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the post insert listener.
+ /// </summary>
+ /// <value>The post insert listener.</value>
+ public IStatementEventListener<PostInsertEvent>[] PostInsertListeners
+ {
+ get { return mappedStatement.PostInsertListeners; }
+ set { mappedStatement.PostInsertListeners = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the pre update listener.
+ /// </summary>
+ /// <value>The pre update listener.</value>
+ public IStatementEventListener<PreUpdateOrDeleteEvent>[] PreUpdateOrDeleteListeners
+ {
+ get { return mappedStatement.PreUpdateOrDeleteListeners; }
+ set { mappedStatement.PreUpdateOrDeleteListeners = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the post update listener.
+ /// </summary>
+ /// <value>The post update listener.</value>
+ public IStatementEventListener<PostUpdateOrDeleteEvent>[] PostUpdateOrDeleteListeners
+ {
+ get { return mappedStatement.PostUpdateOrDeleteListeners; }
+ set { mappedStatement.PostUpdateOrDeleteListeners = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the pre select listener.
+ /// </summary>
+ /// <value>The pre select listener.</value>
+ public IStatementEventListener<PreSelectEvent>[] PreSelectListeners
+ {
+ get { return mappedStatement.PreSelectListeners; }
+ set { mappedStatement.PreSelectListeners = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the post select listener.
+ /// </summary>
+ /// <value>The post select listener.</value>
+ public IStatementEventListener<PostSelectEvent>[] PostSelectListeners
+ {
+ get { return mappedStatement.PostSelectListeners; }
+ set { mappedStatement.PostSelectListeners = value; }
+ }
+
/// <summary>
/// The IPreparedCommand to use
/// </summary>
public IPreparedCommand PreparedCommand
{
- get { return _mappedStatement.PreparedCommand; }
+ get { return mappedStatement.PreparedCommand; }
}
/// <summary>
@@ -77,7 +141,7 @@
/// </summary>
public string Id
{
- get { return _mappedStatement.Id; }
+ get { return mappedStatement.Id; }
}
/// <summary>
@@ -85,7 +149,7 @@
/// </summary>
public IStatement Statement
{
- get { return _mappedStatement.Statement; }
+ get { return mappedStatement.Statement; }
}
/// <summary>
@@ -94,7 +158,7 @@
/// <value>The model store.</value>
public IModelStore ModelStore
{
- get { return _mappedStatement.ModelStore; }
+ get { return mappedStatement.ModelStore; }
}
/// <summary>
@@ -111,11 +175,12 @@
public IDictionary ExecuteQueryForMap(ISession session, object parameterObject, string keyProperty, string valueProperty)
{
IDictionary map = new Hashtable();
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create( request, session, this.Statement, parameterObject );
+ RequestScope request = Statement.Sql.GetRequestScope(this, parameterObject, session);
- CacheKey cacheKey = this.GetCacheKey(request);
+ mappedStatement.PreparedCommand.Create( request, session, Statement, parameterObject );
+
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForMap");
if (keyProperty!=null)
{
@@ -126,11 +191,11 @@
cacheKey.Update(valueProperty);
}
- map = this.Statement.CacheModel[cacheKey] as IDictionary;
+ map = Statement.CacheModel[cacheKey] as IDictionary;
if (map == null)
{
- map = _mappedStatement.RunQueryForMap( request, session, parameterObject, keyProperty, valueProperty, null );
- this.Statement.CacheModel[cacheKey] = map;
+ map = mappedStatement.RunQueryForMap( request, session, parameterObject, keyProperty, valueProperty, null );
+ Statement.CacheModel[cacheKey] = map;
}
return map;
@@ -152,11 +217,11 @@
public IDictionary<K, V> ExecuteQueryForDictionary<K, V>(ISession session, object parameterObject, string keyProperty, string valueProperty)
{
IDictionary<K, V> map = new Dictionary<K, V>();
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
+ RequestScope request = Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
+ mappedStatement.PreparedCommand.Create(request, session, Statement, parameterObject);
- CacheKey cacheKey = this.GetCacheKey(request);
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForMap");
if (keyProperty != null)
{
@@ -167,11 +232,11 @@
cacheKey.Update(valueProperty);
}
- map = this.Statement.CacheModel[cacheKey] as IDictionary<K, V>;
+ map = Statement.CacheModel[cacheKey] as IDictionary<K, V>;
if (map == null)
{
- map = _mappedStatement.RunQueryForDictionary<K, V>(request, session, parameterObject, keyProperty, valueProperty, null);
- this.Statement.CacheModel[cacheKey] = map;
+ map = mappedStatement.RunQueryForDictionary<K, V>(request, session, parameterObject, keyProperty, valueProperty, null);
+ Statement.CacheModel[cacheKey] = map;
}
return map;
@@ -190,7 +255,7 @@
/// <exception cref="Apache.Ibatis.DataMapper.Exceptions.DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
public IDictionary<K, V> ExecuteQueryForDictionary<K, V>(ISession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate<K, V> rowDelegate)
{
- return _mappedStatement.ExecuteQueryForDictionary<K, V>(session, parameterObject, keyProperty, valueProperty, rowDelegate);
+ return mappedStatement.ExecuteQueryForDictionary<K, V>(session, parameterObject, keyProperty, valueProperty, rowDelegate);
}
#endregion
@@ -203,7 +268,7 @@
/// <returns>The number of row effected.</returns>
public int ExecuteUpdate(ISession session, object parameterObject)
{
- return _mappedStatement.ExecuteUpdate(session, parameterObject);
+ return mappedStatement.ExecuteUpdate(session, parameterObject);
}
/// <summary>
@@ -215,7 +280,7 @@
/// <returns>Can return the insert generated key.</returns>
public object ExecuteInsert(ISession session, object parameterObject)
{
- return _mappedStatement.ExecuteInsert(session, parameterObject);
+ return mappedStatement.ExecuteInsert(session, parameterObject);
}
#region ExecuteQueryForList
@@ -228,7 +293,7 @@
/// <param name="resultObject">A strongly typed collection of result objects.</param>
public void ExecuteQueryForList(ISession session, object parameterObject, IList resultObject)
{
- _mappedStatement.ExecuteQueryForList(session, parameterObject, resultObject);
+ mappedStatement.ExecuteQueryForList(session, parameterObject, resultObject);
}
/// <summary>
@@ -240,21 +305,24 @@
public IList ExecuteQueryForList(ISession session, object parameterObject)
{
IList list = null;
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = mappedStatement.LaunchPreEvent(mappedStatement.PreSelectListeners, parameterObject);
+
+ RequestScope request = Statement.Sql.GetRequestScope(this, param, session);
- CacheKey cacheKey = this.GetCacheKey(request);
+ mappedStatement.PreparedCommand.Create(request, session, Statement, param);
+
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForList");
- list = this.Statement.CacheModel[cacheKey] as IList;
+ list = Statement.CacheModel[cacheKey] as IList;
if (list == null)
{
- list = _mappedStatement.RunQueryForList(request, session, parameterObject);
- this.Statement.CacheModel[cacheKey] = list;
+ list = mappedStatement.RunQueryForList(request, session, param);
+ Statement.CacheModel[cacheKey] = list;
}
- return list;
+ return mappedStatement.LaunchPostEvent(mappedStatement.PostSelectListeners, param, list);
}
#endregion
@@ -268,7 +336,7 @@
/// <param name="resultObject">A strongly typed collection of result objects.</param>
public void ExecuteQueryForList<T>(ISession session, object parameterObject, IList<T> resultObject)
{
- _mappedStatement.ExecuteQueryForList(session, parameterObject, resultObject);
+ mappedStatement.ExecuteQueryForList(session, parameterObject, resultObject);
}
/// <summary>
@@ -280,37 +348,29 @@
public IList<T> ExecuteQueryForList<T>(ISession session, object parameterObject)
{
IList<T> list = null;
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = mappedStatement.LaunchPreEvent(mappedStatement.PreSelectListeners, parameterObject);
+
+ RequestScope request = Statement.Sql.GetRequestScope(this, param, session);
+
+ mappedStatement.PreparedCommand.Create(request, session, Statement, param);
- CacheKey cacheKey = this.GetCacheKey(request);
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForList");
- list = this.Statement.CacheModel[cacheKey] as IList<T>;
+ list = Statement.CacheModel[cacheKey] as IList<T>;
if (list == null)
{
- list = _mappedStatement.RunQueryForList<T>(request, session, parameterObject);
- this.Statement.CacheModel[cacheKey] = list;
+ list = mappedStatement.RunQueryForList<T>(request, session, param);
+ Statement.CacheModel[cacheKey] = list;
}
- return list;
+ return mappedStatement.LaunchPostEvent(mappedStatement.PostSelectListeners, param, list);
}
#endregion
#region ExecuteQueryForObject
- /// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- public object ExecuteQueryForObject(ISession session, object parameterObject)
- {
- return this.ExecuteQueryForObject(session, parameterObject, null);
- }
-
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
/// the resultObject passed in as a parameter.
@@ -322,14 +382,17 @@
public object ExecuteQueryForObject(ISession session, object parameterObject, object resultObject)
{
object obj = null;
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create( request, session, this.Statement, parameterObject );
+ object param = mappedStatement.LaunchPreEvent(mappedStatement.PreSelectListeners, parameterObject);
+
+ RequestScope request = Statement.Sql.GetRequestScope(this, param, session);
- CacheKey cacheKey = this.GetCacheKey(request);
+ mappedStatement.PreparedCommand.Create(request, session, Statement, param);
+
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForObject");
- obj = this.Statement.CacheModel[cacheKey];
+ obj = Statement.CacheModel[cacheKey];
// check if this query has alreay been run
if (obj == CacheModel.NULL_OBJECT)
{
@@ -338,25 +401,16 @@
}
else if (obj ==null)
{
- obj = _mappedStatement.RunQueryForObject(request, session, parameterObject, resultObject);
- this.Statement.CacheModel[cacheKey] = obj;
+ obj = mappedStatement.RunQueryForObject(request, session, param, resultObject);
+ Statement.CacheModel[cacheKey] = obj;
}
- return obj;
+ return mappedStatement.LaunchPostEvent(mappedStatement.PostSelectListeners, param, obj);
}
+
#endregion
#region ExecuteQueryForObject .NET 2.0
- /// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- public T ExecuteQueryForObject<T>(ISession session, object parameterObject)
- {
- return this.ExecuteQueryForObject<T>(session, parameterObject, default(T));
- }
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
@@ -369,14 +423,17 @@
public T ExecuteQueryForObject<T>(ISession session, object parameterObject, T resultObject)
{
T obj = default(T);
- RequestScope request = this.Statement.Sql.GetRequestScope(this, parameterObject, session);
- _mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = mappedStatement.LaunchPreEvent(mappedStatement.PreSelectListeners, parameterObject);
- CacheKey cacheKey = this.GetCacheKey(request);
+ RequestScope request = Statement.Sql.GetRequestScope(this, param, session);
+
+ mappedStatement.PreparedCommand.Create(request, session, Statement, param);
+
+ CacheKey cacheKey = GetCacheKey(request);
cacheKey.Update("ExecuteQueryForObject");
- object cacheObjet = this.Statement.CacheModel[cacheKey];
+ object cacheObjet = Statement.CacheModel[cacheKey];
// check if this query has alreay been run
if (cacheObjet is T)
{
@@ -389,12 +446,13 @@
}
else //if ((object)obj == null)
{
- obj = (T)_mappedStatement.RunQueryForObject(request, session, parameterObject, resultObject);
- this.Statement.CacheModel[cacheKey] = obj;
+ obj = (T)mappedStatement.RunQueryForObject(request, session, param, resultObject);
+ Statement.CacheModel[cacheKey] = obj;
}
- return obj;
+ return mappedStatement.LaunchPostEvent(mappedStatement.PostSelectListeners, param, obj);
}
+
#endregion
/// <summary>
@@ -406,7 +464,7 @@
/// <param name="rowDelegate"></param>
public IList ExecuteQueryForRowDelegate(ISession session, object parameterObject, RowDelegate rowDelegate)
{
- return _mappedStatement.ExecuteQueryForRowDelegate(session, parameterObject, rowDelegate);
+ return mappedStatement.ExecuteQueryForRowDelegate(session, parameterObject, rowDelegate);
}
/// <summary>
@@ -418,7 +476,7 @@
/// <param name="rowDelegate"></param>
public IList<T> ExecuteQueryForRowDelegate<T>(ISession session, object parameterObject, RowDelegate<T> rowDelegate)
{
- return _mappedStatement.ExecuteQueryForRowDelegate<T>(session, parameterObject, rowDelegate);
+ return mappedStatement.ExecuteQueryForRowDelegate<T>(session, parameterObject, rowDelegate);
}
/// <summary>
@@ -434,7 +492,7 @@
/// <exception cref="Apache.Ibatis.DataMapper.Exceptions.DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
public IDictionary ExecuteQueryForMapWithRowDelegate(ISession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate)
{
- return _mappedStatement.ExecuteQueryForMapWithRowDelegate(session, parameterObject, keyProperty, valueProperty, rowDelegate);
+ return mappedStatement.ExecuteQueryForMapWithRowDelegate(session, parameterObject, keyProperty, valueProperty, rowDelegate);
}
#endregion
@@ -445,9 +503,9 @@
/// <returns>The percentage of hits (0-1), or -1 if cache is disabled.</returns>
public double GetDataCacheHitRatio()
{
- if (_mappedStatement.Statement.CacheModel != null)
+ if (mappedStatement.Statement.CacheModel != null)
{
- return _mappedStatement.Statement.CacheModel.HitRatio;
+ return mappedStatement.Statement.CacheModel.HitRatio;
}
else
{
@@ -473,16 +531,16 @@
}
}
- cacheKey.Update(_mappedStatement.Id);
- cacheKey.Update(_mappedStatement.ModelStore.SessionFactory.DataSource.ConnectionString);
+ cacheKey.Update(mappedStatement.Id);
+ cacheKey.Update(mappedStatement.ModelStore.SessionFactory.DataSource.ConnectionString);
cacheKey.Update(request.IDbCommand.CommandText);
- CacheModel cacheModel = _mappedStatement.Statement.CacheModel;
+ CacheModel cacheModel = mappedStatement.Statement.CacheModel;
if (!cacheModel.IsReadOnly && !cacheModel.IsSerializable)
{
cacheKey.Update(request);
}
return cacheKey;
}
- }
+ }
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/DeleteMappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/DeleteMappedStatement.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/DeleteMappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/DeleteMappedStatement.cs Sun Jun 8 11:20:44 2008
@@ -127,17 +127,6 @@
/// </summary>
/// <param name="session"></param>
/// <param name="parameterObject"></param>
- /// <returns></returns>
- public override object ExecuteQueryForObject(ISession session, object parameterObject)
- {
- throw new DataMapperException("Delete statements cannot be executed as a query for object.");
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="session"></param>
- /// <param name="parameterObject"></param>
/// <param name="resultObject"></param>
/// <returns></returns>
public override object ExecuteQueryForObject(ISession session, object parameterObject, object resultObject)
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs Sun Jun 8 11:20:44 2008
@@ -29,6 +29,8 @@
using System.Collections.Generic;
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
+using Apache.Ibatis.DataMapper.Model.Events;
+using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Session;
#endregion
@@ -80,6 +82,40 @@
/// <value>The model store.</value>
IModelStore ModelStore { get; }
+ /// <summary>
+ /// Gets or sets the pre insert listener.
+ /// </summary>
+ /// <value>The pre insert listener.</value>
+ IStatementEventListener<PreInsertEvent>[] PreInsertListeners { get; set;}
+ /// <summary>
+ /// Gets or sets the post insert listener.
+ /// </summary>
+ /// <value>The post insert listener.</value>
+ IStatementEventListener<PostInsertEvent>[] PostInsertListeners { get; set;}
+
+ /// <summary>
+ /// Gets or sets the pre update listener.
+ /// </summary>
+ /// <value>The pre update listener.</value>
+ IStatementEventListener<PreUpdateOrDeleteEvent>[] PreUpdateOrDeleteListeners { get; set;}
+ /// <summary>
+ /// Gets or sets the post update listener.
+ /// </summary>
+ /// <value>The post update listener.</value>
+ IStatementEventListener<PostUpdateOrDeleteEvent>[] PostUpdateOrDeleteListeners { get; set;}
+
+ /// <summary>
+ /// Gets or sets the pre select listener.
+ /// </summary>
+ /// <value>The pre select listener.</value>
+ IStatementEventListener<PreSelectEvent>[] PreSelectListeners { get; set;}
+
+ /// <summary>
+ /// Gets or sets the post select listener.
+ /// </summary>
+ /// <value>The post select listener.</value>
+ IStatementEventListener<PostSelectEvent>[] PostSelectListeners { get; set;}
+
#endregion
#region ExecuteQueryForMap
@@ -195,13 +231,6 @@
#region ExecuteForObject
- /// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- object ExecuteQueryForObject( ISession session, object parameterObject );
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
@@ -218,14 +247,6 @@
#region ExecuteForObject .NET 2.0
/// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- T ExecuteQueryForObject<T>(ISession session, object parameterObject);
-
- /// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
/// the resultObject passed in as a parameter.
/// </summary>
@@ -234,6 +255,7 @@
/// <param name="resultObject">The result object.</param>
/// <returns>The object</returns>
T ExecuteQueryForObject<T>(ISession session, object parameterObject, T resultObject);
+
#endregion
#region Delegate
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/InsertMappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/InsertMappedStatement.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/InsertMappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/InsertMappedStatement.cs Sun Jun 8 11:20:44 2008
@@ -143,17 +143,6 @@
/// </summary>
/// <param name="session"></param>
/// <param name="parameterObject"></param>
- /// <returns></returns>
- public override object ExecuteQueryForObject(ISession session, object parameterObject )
- {
- throw new DataMapperException("Insert statements cannot be executed as a query for object.");
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="session"></param>
- /// <param name="parameterObject"></param>
/// <param name="resultObject"></param>
/// <returns></returns>
public override object ExecuteQueryForObject(ISession session, object parameterObject, object resultObject)
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs Sun Jun 8 11:20:44 2008
@@ -37,6 +37,8 @@
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
+using Apache.Ibatis.DataMapper.Model.Events;
+using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.ParameterMapping;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.MappedStatements.ResultStrategy;
@@ -45,6 +47,7 @@
using Apache.Ibatis.DataMapper.Exceptions;
using Apache.Ibatis.DataMapper.TypeHandlers;
using Apache.Ibatis.DataMapper.Session;
+using System.Diagnostics;
#endregion
@@ -52,8 +55,9 @@
{
/// <summary>
- /// Summary description for MappedStatement.
+ /// Base implementation of <see cref="IMappedStatement"/>.
/// </summary>
+ [DebuggerDisplay("MappedStatement: {Id}")]
public class MappedStatement : IMappedStatement
{
/// <summary>
@@ -66,154 +70,131 @@
private readonly IModelStore modelStore = null;
private readonly IPreparedCommand preparedCommand = null;
private readonly IResultStrategy resultStrategy = null;
- #endregion
- #region Properties
+ protected IStatementEventListener<PreInsertEvent>[] preInsertListeners = new IStatementEventListener<PreInsertEvent>[] { };
+ protected IStatementEventListener<PostInsertEvent>[] postInsertListeners = new IStatementEventListener<PostInsertEvent>[] { };
+
+ protected IStatementEventListener<PreUpdateOrDeleteEvent>[] preUpdateOrDeleteListeners = new IStatementEventListener<PreUpdateOrDeleteEvent>[] { };
+ protected IStatementEventListener<PostUpdateOrDeleteEvent>[] postUpdateOrDeleteListeners = new IStatementEventListener<PostUpdateOrDeleteEvent>[] { };
+
+ protected IStatementEventListener<PreSelectEvent>[] preSelectListeners = new IStatementEventListener<PreSelectEvent>[] { };
+ protected IStatementEventListener<PostSelectEvent>[] postSelectListeners = new IStatementEventListener<PostSelectEvent>[] { };
+ #endregion
/// <summary>
- /// The IPreparedCommand to use
+ /// Initializes a new instance of the <see cref="MappedStatement"/> class.
/// </summary>
- public IPreparedCommand PreparedCommand
+ /// <param name="modelStore">The model store.</param>
+ /// <param name="statement">The statement.</param>
+ public MappedStatement(IModelStore modelStore, IStatement statement)
{
- get { return preparedCommand; }
+ this.modelStore = modelStore;
+ this.statement = statement;
+ preparedCommand = new DefaultPreparedCommand();
+ resultStrategy = ResultStrategyFactory.Get(this.statement);
}
+ #region IDataMapper Members
+
+ #region properties
/// <summary>
- /// Name used to identify the MappedStatement amongst the others.
- /// This the name of the SQL statement by default.
+ /// Gets or sets the pre insert listener.
/// </summary>
- public string Id
+ /// <value>The pre insert listener.</value>
+ public IStatementEventListener<PreInsertEvent>[] PreInsertListeners
{
- get { return statement.Id; }
+ get { return preInsertListeners; }
+ set { preInsertListeners = value; }
}
/// <summary>
- /// The SQL statment used by this MappedStatement
+ /// Gets or sets the post insert listener.
/// </summary>
- public IStatement Statement
+ /// <value>The post insert listener.</value>
+ public IStatementEventListener<PostInsertEvent>[] PostInsertListeners
{
- get { return statement; }
+ get { return postInsertListeners; }
+ set { postInsertListeners = value; }
}
/// <summary>
- /// The <see cref="IModelStore"/> used by this MappedStatement
+ /// Gets or sets the pre update listener.
/// </summary>
- /// <value>The model store.</value>
- public IModelStore ModelStore
+ /// <value>The pre update listener.</value>
+ public IStatementEventListener<PreUpdateOrDeleteEvent>[] PreUpdateOrDeleteListeners
{
- get { return modelStore; }
+ get { return preUpdateOrDeleteListeners; }
+ set { preUpdateOrDeleteListeners = value; }
}
- #endregion
-
- #region Constructor (s) / Destructor
/// <summary>
- /// Initializes a new instance of the <see cref="MappedStatement"/> class.
+ /// Gets or sets the post update listener.
/// </summary>
- /// <param name="modelStore">The model store.</param>
- /// <param name="statement">The statement.</param>
- public MappedStatement(IModelStore modelStore, IStatement statement)
+ /// <value>The post update listener.</value>
+ public IStatementEventListener<PostUpdateOrDeleteEvent>[] PostUpdateOrDeleteListeners
{
- this.modelStore = modelStore;
- this.statement = statement;
- preparedCommand = new DefaultPreparedCommand();
- resultStrategy = ResultStrategyFactory.Get(this.statement);
+ get { return postUpdateOrDeleteListeners; }
+ set { postUpdateOrDeleteListeners = value; }
}
- #endregion
-
- #region Methods
/// <summary>
- /// Retrieve the output parameter and map them on the result object.
- /// This routine is only use is you specified a ParameterMap and some output attribute
- /// or if you use a store procedure with output parameter...
+ /// Gets or sets the pre select listener.
/// </summary>
- /// <param name="request"></param>
- /// <param name="session">The current session.</param>
- /// <param name="result">The result object.</param>
- /// <param name="command">The command sql.</param>
- private void RetrieveOutputParameters(RequestScope request, ISession session, IDbCommand command, object result)
+ /// <value>The pre select listener.</value>
+ public IStatementEventListener<PreSelectEvent>[] PreSelectListeners
{
- if (request.ParameterMap != null)
- {
- int count = request.ParameterMap.PropertiesList.Count;
- for (int i = 0; i < count; i++)
- {
- ParameterProperty mapping = request.ParameterMap.GetProperty(i);
- if (mapping.Direction == ParameterDirection.Output ||
- mapping.Direction == ParameterDirection.InputOutput)
- {
- string parameterName = string.Empty;
- if (session.SessionFactory.DataSource.DbProvider.UseParameterPrefixInParameter == false)
- {
- parameterName = mapping.ColumnName;
- }
- else
- {
- parameterName = session.SessionFactory.DataSource.DbProvider.ParameterPrefix +
- mapping.ColumnName;
- }
-
- if (mapping.TypeHandler == null) // Find the TypeHandler
- {
- lock (mapping)
- {
- if (mapping.TypeHandler == null)
- {
- Type propertyType = ObjectProbe.GetMemberTypeForGetter(result, mapping.PropertyName);
-
- mapping.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
- }
- }
- }
-
- // Fix IBATISNET-239
- //"Normalize" System.DBNull parameters
- IDataParameter dataParameter = (IDataParameter)command.Parameters[parameterName];
- object dbValue = dataParameter.Value;
-
- object value = null;
-
- bool wasNull = (dbValue == DBNull.Value);
- if (wasNull)
- {
- if (mapping.HasNullValue)
- {
- value = mapping.TypeHandler.ValueOf(mapping.GetAccessor.MemberType, mapping.NullValue);
- }
- else
- {
- value = mapping.TypeHandler.NullValue;
- }
- }
- else
- {
- value = mapping.TypeHandler.GetDataBaseValue(dataParameter.Value, result.GetType());
- }
-
- request.IsRowDataFound = request.IsRowDataFound || (value != null);
+ get { return preSelectListeners; }
+ set { preSelectListeners = value; }
+ }
- request.ParameterMap.SetOutputParameter(ref result, mapping, value);
- }
- }
- }
+ /// <summary>
+ /// Gets or sets the post select listener.
+ /// </summary>
+ /// <value>The post select listener.</value>
+ public IStatementEventListener<PostSelectEvent>[] PostSelectListeners
+ {
+ get { return postSelectListeners; }
+ set { postSelectListeners = value; }
}
+ /// <summary>
+ /// The IPreparedCommand to use
+ /// </summary>
+ public IPreparedCommand PreparedCommand
+ {
+ get { return preparedCommand; }
+ }
- #region ExecuteForObject
+ /// <summary>
+ /// Name used to identify the MappedStatement amongst the others.
+ /// This the name of the SQL statement by default.
+ /// </summary>
+ public string Id
+ {
+ get { return statement.Id; }
+ }
/// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
+ /// The SQL statment used by this MappedStatement
/// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- public virtual object ExecuteQueryForObject(ISession session, object parameterObject)
+ public IStatement Statement
{
- return ExecuteQueryForObject(session, parameterObject, null);
+ get { return statement; }
}
+ /// <summary>
+ /// The <see cref="IModelStore"/> used by this MappedStatement
+ /// </summary>
+ /// <value>The model store.</value>
+ public IModelStore ModelStore
+ {
+ get { return modelStore; }
+ }
+ #endregion
+
+ #region ExecuteForObject
+
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
@@ -226,15 +207,16 @@
public virtual object ExecuteQueryForObject(ISession session, object parameterObject, object resultObject)
{
object obj = null;
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
- obj = RunQueryForObject(request, session, parameterObject, resultObject);
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+ preparedCommand.Create(request, session, Statement, param);
- return obj;
- }
+ obj = RunQueryForObject(request, session, param, resultObject);
+ return LaunchPostEvent(postSelectListeners, param, obj);
+ }
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
@@ -263,17 +245,13 @@
}
}
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
#region remark
// If you are using the OleDb data provider (as you are), you need to close the
@@ -293,18 +271,6 @@
#region ExecuteForObject .NET 2.0
/// <summary>
- /// Executes an SQL statement that returns a single row as an Object.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <returns>The object</returns>
- public virtual T ExecuteQueryForObject<T>(ISession session, object parameterObject)
- {
- return ExecuteQueryForObject<T>(session, parameterObject, default(T));
- }
-
-
- /// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
/// the resultObject passed in as a parameter.
/// </summary>
@@ -315,13 +281,16 @@
public virtual T ExecuteQueryForObject<T>(ISession session, object parameterObject, T resultObject)
{
T obj = default(T);
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
- obj = RunQueryForObject<T>(request, session, parameterObject, resultObject);
+ preparedCommand.Create(request, session, Statement, param);
- return obj;
+ obj = RunQueryForObject<T>(request, session, param, resultObject);
+
+ return LaunchPostEvent(postSelectListeners, param, obj);
}
@@ -352,17 +321,13 @@
}
}
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
#region remark
// If you are using the OleDb data provider, you need to close the
@@ -381,6 +346,7 @@
#region ExecuteQueryForList
+
/// <summary>
/// Runs a query with a custom object that gets a chance
/// to deal with each row as it is processed.
@@ -390,16 +356,20 @@
/// <param name="rowDelegate"></param>
public virtual IList ExecuteQueryForRowDelegate(ISession session, object parameterObject, RowDelegate rowDelegate)
{
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+
+ preparedCommand.Create(request, session, Statement, param);
if (rowDelegate == null)
{
throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
}
- return RunQueryForList(request, session, parameterObject, null, rowDelegate);
+ IList list = RunQueryForList(request, session, param, null, rowDelegate);
+
+ return LaunchPostEvent(postSelectListeners, param, list);
}
/// <summary>
@@ -422,7 +392,7 @@
throw new DataMapperException("A null DictionaryRowDelegate was passed to QueryForMapWithRowDelegate.");
}
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, parameterObject);
return RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, rowDelegate);
}
@@ -436,13 +406,35 @@
/// <returns>A List of result objects.</returns>
public virtual IList ExecuteQueryForList(ISession session, object parameterObject)
{
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+
+ preparedCommand.Create(request, session, Statement, param);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ IList list = RunQueryForList(request, session, param);
- return RunQueryForList(request, session, parameterObject);
+ return LaunchPostEvent(postSelectListeners, param, list);
}
+ /// <summary>
+ /// Executes the SQL and and fill a strongly typed collection.
+ /// </summary>
+ /// <param name="session">The session used to execute the statement.</param>
+ /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+ /// <param name="resultObject">A strongly typed collection of result objects.</param>
+ public virtual void ExecuteQueryForList(ISession session, object parameterObject, IList resultObject)
+ {
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+
+ preparedCommand.Create(request, session, Statement, param);
+
+ RunQueryForList(request, session, param, resultObject, null);
+
+ LaunchPostEvent(postSelectListeners, param, resultObject);
+ }
/// <summary>
/// Runs the query for list.
@@ -484,17 +476,13 @@
}
while (reader.NextResult());
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
RetrieveOutputParameters(request, session, command, parameterObject);
}
@@ -557,17 +545,13 @@
}
while (reader.NextResult());
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
RetrieveOutputParameters(request, session, command, parameterObject);
}
@@ -575,22 +559,6 @@
}
- /// <summary>
- /// Executes the SQL and and fill a strongly typed collection.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <param name="resultObject">A strongly typed collection of result objects.</param>
- public virtual void ExecuteQueryForList(ISession session, object parameterObject, IList resultObject)
- {
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
-
- preparedCommand.Create(request, session, this.Statement, parameterObject);
-
- RunQueryForList(request, session, parameterObject, resultObject, null);
- }
-
-
#endregion
#region ExecuteQueryForList .NET 2.0
@@ -604,15 +572,19 @@
/// <param name="rowDelegate"></param>
public virtual IList<T> ExecuteQueryForRowDelegate<T>(ISession session, object parameterObject, RowDelegate<T> rowDelegate)
{
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, param);
if (rowDelegate == null)
{
throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
}
- return RunQueryForList<T>(request, session, parameterObject, null, rowDelegate);
+ IList<T> list = RunQueryForList<T>(request, session, param, null, rowDelegate);
+
+ return LaunchPostEvent(postSelectListeners, param, list);
}
@@ -624,11 +596,34 @@
/// <returns>A List of result objects.</returns>
public virtual IList<T> ExecuteQueryForList<T>(ISession session, object parameterObject)
{
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
- return RunQueryForList<T>(request, session, parameterObject, null, null);
+ preparedCommand.Create(request, session, Statement, param);
+
+ IList<T> list = RunQueryForList<T>(request, session, param, null, null);
+
+ return LaunchPostEvent(postSelectListeners, param, list);
+ }
+
+ /// <summary>
+ /// Executes the SQL and and fill a strongly typed collection.
+ /// </summary>
+ /// <param name="session">The session used to execute the statement.</param>
+ /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+ /// <param name="resultObject">A strongly typed collection of result objects.</param>
+ public virtual void ExecuteQueryForList<T>(ISession session, object parameterObject, IList<T> resultObject)
+ {
+ object param = LaunchPreEvent(preSelectListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+
+ preparedCommand.Create(request, session, Statement, param);
+
+ RunQueryForList<T>(request, session, param, resultObject, null);
+
+ LaunchPostEvent(postSelectListeners, param, resultObject);
}
/// <summary>
@@ -669,17 +664,13 @@
}
while (reader.NextResult());
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
RetrieveOutputParameters(request, session, command, parameterObject);
}
@@ -742,37 +733,19 @@
}
while (reader.NextResult());
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
RetrieveOutputParameters(request, session, command, parameterObject);
}
return list;
}
- /// <summary>
- /// Executes the SQL and and fill a strongly typed collection.
- /// </summary>
- /// <param name="session">The session used to execute the statement.</param>
- /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
- /// <param name="resultObject">A strongly typed collection of result objects.</param>
- public virtual void ExecuteQueryForList<T>(ISession session, object parameterObject, IList<T> resultObject)
- {
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
-
- preparedCommand.Create(request, session, this.Statement, parameterObject);
-
- RunQueryForList<T>(request, session, parameterObject, resultObject, null);
- }
#endregion
@@ -789,20 +762,23 @@
public virtual int ExecuteUpdate(ISession session, object parameterObject)
{
int rows = 0; // the number of rows affected
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ object param = LaunchPreEvent(preUpdateOrDeleteListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
+
+ preparedCommand.Create(request, session, Statement, param);
using (IDbCommand command = request.IDbCommand)
{
rows = command.ExecuteNonQuery();
- RetrieveOutputParameters(request, session, command, parameterObject);
+ RetrieveOutputParameters(request, session, command, param);
}
RaiseExecuteEvent();
- return rows;
+ return LaunchPostEvent(postUpdateOrDeleteListeners, param, rows);
}
@@ -817,7 +793,10 @@
{
object generatedKey = null;
SelectKey selectKeyStatement = null;
- RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
+
+ object param = LaunchPreEvent(preInsertListeners, parameterObject);
+
+ RequestScope request = statement.Sql.GetRequestScope(this, param, session);
if (statement is Insert)
{
@@ -827,14 +806,15 @@
if (selectKeyStatement != null && !selectKeyStatement.isAfter)
{
IMappedStatement mappedStatement = modelStore.GetMappedStatement(selectKeyStatement.Id);
- generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
+ generatedKey = mappedStatement.ExecuteQueryForObject(session, param, null);
- ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey,
+ ObjectProbe.SetMemberValue(param, selectKeyStatement.PropertyName, generatedKey,
request.DataExchangeFactory.ObjectFactory,
request.DataExchangeFactory.AccessorFactory);
}
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, param);
+
using (IDbCommand command = request.IDbCommand)
{
if (statement is Insert)
@@ -869,19 +849,19 @@
if (selectKeyStatement != null && selectKeyStatement.isAfter)
{
IMappedStatement mappedStatement = modelStore.GetMappedStatement(selectKeyStatement.Id);
- generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
+ generatedKey = mappedStatement.ExecuteQueryForObject(session, param, null);
- ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey,
+ ObjectProbe.SetMemberValue(param, selectKeyStatement.PropertyName, generatedKey,
request.DataExchangeFactory.ObjectFactory,
request.DataExchangeFactory.AccessorFactory);
}
- RetrieveOutputParameters(request, session, command, parameterObject);
+ RetrieveOutputParameters(request, session, command, param);
}
RaiseExecuteEvent();
- return generatedKey;
+ return LaunchPostEvent(postInsertListeners, param, generatedKey);
}
#endregion
@@ -903,7 +883,7 @@
{
RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, parameterObject);
return RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, null);
}
@@ -967,16 +947,12 @@
}
}
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
}
return map;
@@ -997,7 +973,7 @@
{
RequestScope request = statement.Sql.GetRequestScope(this, parameterObject, session);
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, parameterObject);
return RunQueryForDictionary<K, V>(request, session, parameterObject, keyProperty, valueProperty, null);
@@ -1023,7 +999,7 @@
throw new DataMapperException("A null DictionaryRowDelegate was passed to QueryForDictionary.");
}
- preparedCommand.Create(request, session, this.Statement, parameterObject);
+ preparedCommand.Create(request, session, Statement, parameterObject);
return RunQueryForDictionary<K, V>(request, session, parameterObject, keyProperty, valueProperty, rowDelegate);
}
@@ -1093,16 +1069,12 @@
}
}
}
- catch
- {
- throw;
- }
finally
{
reader.Close();
reader.Dispose();
}
- ExecuteDeferredLoad(request);
+ ExecuteDelayedLoad(request);
}
return map;
@@ -1110,22 +1082,98 @@
#endregion
+ #endregion
+
+ /// <summary>
+ /// Retrieve the output parameter and map them on the result object.
+ /// This routine is only use is you specified a ParameterMap and some output attribute
+ /// or if you use a store procedure with output parameter...
+ /// </summary>
+ /// <param name="request"></param>
+ /// <param name="session">The current session.</param>
+ /// <param name="result">The result object.</param>
+ /// <param name="command">The command sql.</param>
+ private static void RetrieveOutputParameters(RequestScope request, ISession session, IDbCommand command, object result)
+ {
+ if (request.ParameterMap != null)
+ {
+ int count = request.ParameterMap.PropertiesList.Count;
+ for (int i = 0; i < count; i++)
+ {
+ ParameterProperty mapping = request.ParameterMap.GetProperty(i);
+ if (mapping.Direction == ParameterDirection.Output ||
+ mapping.Direction == ParameterDirection.InputOutput)
+ {
+ string parameterName = string.Empty;
+ if (session.SessionFactory.DataSource.DbProvider.UseParameterPrefixInParameter == false)
+ {
+ parameterName = mapping.ColumnName;
+ }
+ else
+ {
+ parameterName = session.SessionFactory.DataSource.DbProvider.ParameterPrefix +
+ mapping.ColumnName;
+ }
+
+ if (mapping.TypeHandler == null) // Find the TypeHandler
+ {
+ lock (mapping)
+ {
+ if (mapping.TypeHandler == null)
+ {
+ Type propertyType = ObjectProbe.GetMemberTypeForGetter(result, mapping.PropertyName);
+
+ mapping.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
+ }
+ }
+ }
+
+ // Fix IBATISNET-239
+ //"Normalize" System.DBNull parameters
+ IDataParameter dataParameter = (IDataParameter)command.Parameters[parameterName];
+ object dbValue = dataParameter.Value;
+
+ object value = null;
+
+ bool wasNull = (dbValue == DBNull.Value);
+ if (wasNull)
+ {
+ if (mapping.HasNullValue)
+ {
+ value = mapping.TypeHandler.ValueOf(mapping.GetAccessor.MemberType, mapping.NullValue);
+ }
+ else
+ {
+ value = mapping.TypeHandler.NullValue;
+ }
+ }
+ else
+ {
+ value = mapping.TypeHandler.GetDataBaseValue(dataParameter.Value, result.GetType());
+ }
+
+ request.IsRowDataFound = request.IsRowDataFound || (value != null);
+
+ request.ParameterMap.SetOutputParameter(ref result, mapping, value);
+ }
+ }
+ }
+ }
/// <summary>
/// Executes the <see cref="PostBindind"/>.
/// </summary>
/// <param name="request">The current <see cref="RequestScope"/>.</param>
- private void ExecuteDeferredLoad(RequestScope request)
+ private static void ExecuteDelayedLoad(RequestScope request)
{
- while (request.DeferredLoad.Count > 0)
+ while (request.DelayedLoad.Count > 0)
{
- PostBindind postSelect = request.DeferredLoad.Dequeue();
+ PostBindind postSelect = request.DelayedLoad.Dequeue();
PostSelectStrategyFactory.Get(postSelect.Method).Execute(postSelect, request);
}
}
-
/// <summary>
/// Raise an event ExecuteEventArgs
/// (Used when a query is executed)
@@ -1138,21 +1186,53 @@
}
/// <summary>
- /// ToString implementation.
+ /// Launches the pre event.
/// </summary>
- /// <returns>A string that describes the MappedStatement</returns>
- public override string ToString()
+ /// <param name="listeners">The listeners.</param>
+ /// <param name="parameterObject">The parameter object.</param>
+ internal object LaunchPreEvent<TEvent>(IStatementEventListener<TEvent>[] listeners,
+ object parameterObject) where TEvent : PreStatementEvent, new()
{
- StringBuilder buffer = new StringBuilder();
- buffer.Append("\tMappedStatement: " + this.Id);
- buffer.Append(Environment.NewLine);
- if (statement.ParameterMap != null) buffer.Append(statement.ParameterMap.Id);
-
- return buffer.ToString();
+ object param = parameterObject;
+ if (listeners.Length > 0)
+ {
+ TEvent evnt = new TEvent();
+ evnt.MappedStatement = this;
+ evnt.ParameterObject = param;
+ foreach (IStatementEventListener<TEvent> listener in listeners)
+ {
+ evnt.ParameterObject = listener.OnEvent(evnt);
+ }
+ param = evnt.ParameterObject;
+ }
+ return param;
}
-
- #endregion
-
+ /// <summary>
+ /// Launches the pre event.
+ /// </summary>
+ /// <param name="listeners">The listeners.</param>
+ /// <param name="parameterObject">The parameter object.</param>
+ /// <param name="resultObject">The result object.</param>
+ /// <returns></returns>
+ internal TType LaunchPostEvent<TType, TEvent>(IStatementEventListener<TEvent>[] listeners,
+ object parameterObject,
+ TType resultObject) where TEvent : PostStatementEvent, new()
+ {
+ TType result = resultObject;
+ if (listeners.Length > 0)
+ {
+ TEvent evnt = new TEvent();
+ evnt.MappedStatement = this;
+ evnt.ResultObject = result;
+ evnt.ParameterObject = parameterObject;
+ foreach (IStatementEventListener<TEvent> listener in listeners)
+ {
+ evnt.ResultObject = listener.OnEvent(evnt);
+ }
+ result = (TType)evnt.ResultObject;
+ }
+ return result;
+ }
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostBindind.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostBindind.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostBindind.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostBindind.cs Sun Jun 8 11:20:44 2008
@@ -29,7 +29,7 @@
namespace Apache.Ibatis.DataMapper.MappedStatements
{
/// <summary>
- /// All dataq tor retrieve 'select' <see cref="ResultProperty"/>
+ /// All data to retrieve 'select' <see cref="ResultProperty"/>
/// </summary>
/// <remarks>
/// As ADO.NET allows one open <see cref="IDataReader"/> per connection at once, we keep
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ArrayStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ArrayStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ArrayStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ArrayStrategy.cs Sun Jun 8 11:20:44 2008
@@ -53,7 +53,7 @@
array.SetValue(values[i],i);
}
- postSelect.ResultProperty.SetAccessor.Set(postSelect.Target, array);
+ postSelect.ResultProperty.Set(postSelect.Target, array);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/GenericListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/GenericListStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/GenericListStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/GenericListStrategy.cs Sun Jun 8 11:20:44 2008
@@ -78,7 +78,7 @@
object[] args = { request.Session, postSelect.Keys };
object values = miConstructed.Invoke(postSelect.Statement, args);
- postSelect.ResultProperty.SetAccessor.Set(postSelect.Target, values);
+ postSelect.ResultProperty.Set(postSelect.Target, values);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ListStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ListStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ListStrategy.cs Sun Jun 8 11:20:44 2008
@@ -42,7 +42,7 @@
public void Execute(PostBindind postSelect, RequestScope request)
{
object values = postSelect.Statement.ExecuteQueryForList(request.Session, postSelect.Keys);
- postSelect.ResultProperty.SetAccessor.Set(postSelect.Target, values);
+ postSelect.ResultProperty.Set(postSelect.Target, values);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ObjectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ObjectStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ObjectStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/ObjectStrategy.cs Sun Jun 8 11:20:44 2008
@@ -41,8 +41,8 @@
/// <param name="request">The <see cref="RequestScope"/></param>
public void Execute(PostBindind postSelect, RequestScope request)
{
- object value = postSelect.Statement.ExecuteQueryForObject(request.Session, postSelect.Keys);
- postSelect.ResultProperty.SetAccessor.Set(postSelect.Target, value);
+ object value = postSelect.Statement.ExecuteQueryForObject(request.Session, postSelect.Keys, null);
+ postSelect.ResultProperty.Set(postSelect.Target, value);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/StrongTypedListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/StrongTypedListStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/StrongTypedListStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PostSelectStrategy/StrongTypedListStrategy.cs Sun Jun 8 11:20:44 2008
@@ -48,7 +48,7 @@
IFactory factory = request.DataExchangeFactory.ObjectFactory.CreateFactory(postSelect.ResultProperty.SetAccessor.MemberType, Type.EmptyTypes);
object values = factory.CreateInstance(null);
postSelect.Statement.ExecuteQueryForList(request.Session, postSelect.Keys, (IList)values);
- postSelect.ResultProperty.SetAccessor.Set(postSelect.Target, values);
+ postSelect.ResultProperty.Set(postSelect.Target, values);
}
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/GroupByStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/GroupByStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/GroupByStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/GroupByStrategy.cs Sun Jun 8 11:20:44 2008
@@ -93,7 +93,7 @@
if (property == null)// Create the list if need
{
property = mapping.ListFactory.CreateInstance(null);
- mapping.SetAccessor.Set(target, property);
+ mapping.Set(target, property);
}
list = (IList)property;
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs Sun Jun 8 11:20:44 2008
@@ -78,7 +78,7 @@
for (int index = 0; index < resultMapping.Parameters.Count; index++)
{
ResultProperty resultProperty = resultMapping.Parameters[index];
- parameters[index] = resultProperty.ArgumentStrategy.GetValue(request, resultProperty, ref reader, null);
+ parameters[index] = resultProperty.GetValue(request, ref reader, null);
request.IsRowDataFound = request.IsRowDataFound || (parameters[index] != null);
isParameterFound = isParameterFound || (parameters[index] != null);
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs Sun Jun 8 11:20:44 2008
@@ -66,7 +66,7 @@
throw new NotImplementedException("Lazy load no supported for System.Array property:" + mapping.SetAccessor.Name);
}
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForArrayList;
- request.DeferredLoad.Enqueue(postSelect);
+ request.DelayedLoad.Enqueue(postSelect);
}
/// <summary>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs Sun Jun 8 11:20:44 2008
@@ -67,7 +67,7 @@
if (mapping.IsLazyLoad)
{
object values = mapping.LazyFactory.CreateProxy(request.MappedStatement.ModelStore.DataMapper, selectStatement, keys, target, mapping.SetAccessor);
- mapping.SetAccessor.Set(target, values);
+ mapping.Set(target, values);
}
else
{
@@ -75,7 +75,7 @@
{
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForGenericIList;
}
- request.DeferredLoad.Enqueue(postSelect);
+ request.DelayedLoad.Enqueue(postSelect);
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs Sun Jun 8 11:20:44 2008
@@ -67,7 +67,7 @@
object values = mapping.LazyFactory.CreateProxy(
request.MappedStatement.ModelStore.DataMapper,
selectStatement, keys, target, mapping.SetAccessor);
- mapping.SetAccessor.Set(target, values);
+ mapping.Set(target, values);
}
else
{
@@ -79,7 +79,7 @@
{
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForStrongTypedIList;
}
- request.DeferredLoad.Enqueue(postSelect);
+ request.DelayedLoad.Enqueue(postSelect);
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs Sun Jun 8 11:20:44 2008
@@ -69,12 +69,12 @@
object values = mapping.LazyFactory.CreateProxy(
request.MappedStatement.ModelStore.DataMapper,
selectStatement, keys, target, mapping.SetAccessor);
- mapping.SetAccessor.Set(target, values);
+ mapping.Set(target, values);
}
else
{
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForObject;
- request.DeferredLoad.Enqueue(postSelect);
+ request.DelayedLoad.Enqueue(postSelect);
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs?rev=664536&r1=664535&r2=664536&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs Sun Jun 8 11:20:44 2008
@@ -142,7 +142,7 @@
if (wasNull)
{
// set the value of an object property to null
- mapping.SetAccessor.Set(target, null);
+ mapping.Set(target, null);
}
else // Collection object or .Net object
{