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 2006/03/29 18:16:00 UTC
svn commit: r389819 [1/2] - in /ibatis/trunk/cs/mapper:
IBatisNet.Common.Test/Domain/ IBatisNet.Common/Utilities/Objects/
IBatisNet.Common/Utilities/Objects/Members/ IBatisNet.DataMapper.Test/
IBatisNet.DataMapper.Test/Domain/ IBatisNet.DataMapper.Test...
Author: gbayon
Date: Wed Mar 29 08:15:54 2006
New Revision: 389819
URL: http://svn.apache.org/viewcvs?rev=389819&view=rev
Log:
- Added useReflectionOptimizer attribute setting in SqlMap.config
- Added class attribute to parameterMap tag [This attibrute is required !]
- Added multiple improvements
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs (with props)
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorObjectFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitPropertyAccessor.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Simple.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/ProcedureSql.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/StaticSql.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PaginatedList.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs Wed Mar 29 08:15:54 2006
@@ -38,6 +38,7 @@
private TimeSpan _timeSpan = TimeSpan.MinValue;
private Account _account = null;
private Days _day;
+ private Type _type = null;
#if dotnet2
private Int32? _intNullable = null;
@@ -48,6 +49,11 @@
set { _intNullable = value; }
}
#endif
+
+ public Property()
+ {
+ _type = typeof(int);
+ }
public Days Day
{
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorFactory.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorFactory.cs Wed Mar 29 08:15:54 2006
@@ -1,3 +1,28 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-03-22 22:39:21 +0100 (mer., 22 mars 2006) $
+ * $LastChangedBy: gbayon $
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * 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;
namespace IBatisNet.Common.Utilities.Objects
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorObjectFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorObjectFactory.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorObjectFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ActivatorObjectFactory.cs Wed Mar 29 08:15:54 2006
@@ -1,3 +1,28 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-03-22 22:39:21 +0100 (mer., 22 mars 2006) $
+ * $LastChangedBy: gbayon $
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * 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;
namespace IBatisNet.Common.Utilities.Objects
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitPropertyAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitPropertyAccessor.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitPropertyAccessor.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitPropertyAccessor.cs Wed Mar 29 08:15:54 2006
@@ -160,7 +160,8 @@
protected override void EmitType()
{
// Define a public class named "PropertyAccessorFor.FullTagetTypeName.PropertyName" in the assembly.
- TypeBuilder typeBuilder = moduleBuilder.DefineType("MemberAccessorFor" + targetType.FullName + memberName, TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed);
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("MemberAccessorFor" + targetType.FullName + memberName,
+ TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed);
// Mark the class as implementing IMemberAccessor.
typeBuilder.AddInterfaceImplementation(typeof(IMemberAccessor));
@@ -176,7 +177,8 @@
#region Emit constructor
// Create a new constructor (public)
- ConstructorBuilder cb = typeBuilder.DefineConstructor(MethodAttributes.Public,
+ ConstructorBuilder cb = typeBuilder.DefineConstructor(MethodAttributes.Public
+ | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName,
CallingConventions.Standard, Type.EmptyTypes);
// Get the constructor's IL generator
ILGenerator constructorIL = cb.GetILGenerator();
@@ -191,10 +193,10 @@
constructorIL.Emit(OpCodes.Ldstr, memberName);
constructorIL.Emit(OpCodes.Stfld, fieldBuilderName);
// Store type in field "_memberType"
- // constructorIL.Emit(OpCodes.Ldtoken, baseMemberType);
- // MethodInfo miGetTypeFromHandle = typeof(System.Type).GetMethod("GetTypeFromHandle", new Type[] {typeof(System.RuntimeTypeHandle)});
- // constructorIL.EmitCall(OpCodes.Call, miGetTypeFromHandle, null);
- // constructorIL.Emit(OpCodes.Stfld, fieldBuilderMemberType);
+// constructorIL.Emit(OpCodes.Ldtoken, baseMemberType);
+// MethodInfo miGetTypeFromHandle = typeof(System.Type).GetMethod("GetTypeFromHandle", new Type[] {typeof(System.RuntimeTypeHandle)});
+// constructorIL.EmitCall(OpCodes.Call, miGetTypeFromHandle, null);
+// constructorIL.Emit(OpCodes.Stfld, fieldBuilderMemberType);
// Emit return opcode
constructorIL.Emit(OpCodes.Ret);
#endregion
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -325,8 +325,6 @@
/// <returns></returns>
protected static object GetProperty(object obj, string propertyName)
{
- ReflectionInfo reflectionCache = ReflectionInfo.GetInstance(obj.GetType());
-
try
{
object value = null;
@@ -343,6 +341,7 @@
}
else
{
+ ReflectionInfo reflectionCache = ReflectionInfo.GetInstance(obj.GetType());
PropertyInfo propertyInfo = reflectionCache.GetGetter(propertyName);
if (propertyInfo == null)
{
@@ -431,8 +430,6 @@
/// <param name="propertyValue"></param>
protected static void SetProperty(object obj, string propertyName, object propertyValue)
{
- ReflectionInfo reflectionCache = ReflectionInfo.GetInstance(obj.GetType());
-
try
{
if (propertyName.IndexOf("[") > -1)
@@ -447,6 +444,7 @@
}
else
{
+ ReflectionInfo reflectionCache = ReflectionInfo.GetInstance(obj.GetType());
PropertyInfo propertyInfo = reflectionCache.GetSetter(propertyName);
if (propertyInfo == null)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs Wed Mar 29 08:15:54 2006
@@ -6,7 +6,7 @@
namespace IBatisNet.DataMapper.Test.Domain
{
- class NullableClass
+ public class NullableClass
{
#if dotnet2
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Simple.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Simple.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Simple.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Simple.cs Wed Mar 29 08:15:54 2006
@@ -4,7 +4,7 @@
namespace IBatisNet.DataMapper.Test.Domain
{
[Serializable]
- class Simple
+ public class Simple
{
private string _name = string.Empty;
private string _address = string.Empty;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj Wed Mar 29 08:15:54 2006
@@ -502,6 +502,10 @@
BuildAction = "Content"
/>
<File
+ RelPath = "Maps\MSSQL\SqlClient\Nullable.xml"
+ BuildAction = "Content"
+ />
+ <File
RelPath = "Maps\MSSQL\SqlClient\Order.xml"
BuildAction = "Content"
/>
@@ -723,6 +727,10 @@
/>
<File
RelPath = "Maps\PostgreSQL\Npgsql\LineItem.xml"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "Maps\PostgreSQL\Npgsql\Nullable.xml"
BuildAction = "Content"
/>
<File
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml Wed Mar 29 08:15:54 2006
@@ -594,16 +594,16 @@
============================================= -->
<parameterMaps>
- <parameterMap id="swap-params">
+ <parameterMap id="swap-params" class="Hashtable">
<parameter property="email1" column="First_Email" />
<parameter property="email2" column="Second_Email" />
</parameterMap>
- <parameterMap id="select-params">
+ <parameterMap id="select-params" class="Hashtable">
<parameter property="Account_ID" />
</parameterMap>
- <parameterMap id="insert-params">
+ <parameterMap id="insert-params" class="Account">
<parameter property="Id" />
<parameter property="FirstName" />
<parameter property="LastName" />
@@ -612,14 +612,14 @@
<parameter property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</parameterMap>
- <parameterMap id="update-params">
+ <parameterMap id="update-params" class="Account">
<parameter property="FirstName" />
<parameter property="LastName" />
<parameter property="EmailAddress" nullValue="no_email@provided.com"/>
<parameter property="Id" />
</parameterMap>
- <parameterMap id="update-params2">
+ <parameterMap id="update-params2" class="Account">
<parameter property="Id" />
<parameter property="FirstName" />
<parameter property="LastName" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml Wed Mar 29 08:15:54 2006
@@ -107,10 +107,14 @@
Category_Id = ?
</update>
+ <procedure id="InsertCategoryViaStoreProcedureWithMap" parameterMap="insertMap-params">
+ ps_InsertCategorie
+ </procedure>
+
<procedure id="InsertCategoryViaStoreProcedure" parameterMap="insert-params">
ps_InsertCategorie
</procedure>
-
+
<insert id="InsertCategoryGenerate" parameterMap="insert-generate-params">
<selectKey property="Id" type="post" resultClass="int">
select @@IDENTITY as value
@@ -151,43 +155,50 @@
</statements>
<parameterMaps>
- <parameterMap id="insert-params">
+
+ <parameterMap id="insertMap-params" class="Hashtable">
+ <parameter property="Id" column="Category_Id" dbType="Int" /><!-- Int for SqlClient, Obdc; Integer for Oledb -->
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+ </parameterMap>
+
+ <parameterMap id="insert-params" class="Category">
<parameter property="Id" column="Category_Id" dbType="Int" /><!-- Int for SqlClient, Obdc; Integer for Oledb -->
<parameter property="Name" column="Category_Name"/>
<parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
</parameterMap>
- <parameterMap id="InsertParam">
+ <parameterMap id="InsertParam" class="Category">
<parameter property="Name" column="Category_Name"/>
<parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
</parameterMap>
- <parameterMap id="insert-null-params">
+ <parameterMap id="insert-null-params" class="Category">
<parameter property="Name" column="Category_Name"/>
<parameter property="Guid" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
</parameterMap>
- <parameterMap id="UpdateParam" extends="InsertParam">
+ <parameterMap id="UpdateParam" extends="InsertParam" class="Category">
<parameter property="Id" column="Category_Id" />
</parameterMap>
<!-- Used by generated statement -->
- <parameterMap id="insert-generate-params">
+ <parameterMap id="insert-generate-params" class="Category">
<parameter property="Name" column="Category_Name"/>
<parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
</parameterMap>
- <parameterMap id="update-generate-params" extends="insert-generate-params">
+ <parameterMap id="update-generate-params" extends="insert-generate-params" class="Category">
<parameter property="Id" column="Category_Id" />
</parameterMap>
- <parameterMap id="delete-generate-params">
+ <parameterMap id="delete-generate-params" class="Category">
<parameter property="Id" column="Category_Id" />
<parameter property="Name" column="Category_Name"/>
</parameterMap>
- <parameterMap id="select-generate-params">
+ <parameterMap id="select-generate-params" class="Category">
<parameter property="Id" column="Category_Id" />
<parameter property="Name" column="Category_Name"/>
<parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml Wed Mar 29 08:15:54 2006
@@ -50,7 +50,7 @@
</statements>
<parameterMaps>
- <parameterMap id="insert-params">
+ <parameterMap id="insert-params" class="Enumeration">
<parameter property="Id" column="Enum_ID" />
<parameter property="Day" column="Enum_Day"/>
<parameter property="Color" column="Enum_Color" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml Wed Mar 29 08:15:54 2006
@@ -183,11 +183,11 @@
<parameterMaps>
- <parameterMap id="select-params">
+ <parameterMap id="select-params" class="Hashtable">
<parameter property="Order_ID" />
</parameterMap>
- <parameterMap id="insert-params">
+ <parameterMap id="insert-params" class="LineItem">
<parameter property="Id" />
<parameter property="Order.Id" />
<parameter property="Code" />
@@ -195,7 +195,7 @@
<parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
</parameterMap>
- <parameterMap id="insert-params-picture">
+ <parameterMap id="insert-params-picture" class="LineItem">
<parameter property="Id" />
<parameter property="Order.Id" />
<parameter property="Code" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml Wed Mar 29 08:15:54 2006
@@ -489,7 +489,7 @@
<parameterMaps>
- <parameterMap id="insert-params">
+ <parameterMap id="insert-params" class="Order">
<parameter property="Id" dbType="Int"/> <!-- Int for SqlClient, Obdc; Integer for Oledb -->
<parameter property="Account.Id"/>
<parameter property="Date" nullValue="01/01/0001 00:00:00" />
@@ -502,7 +502,7 @@
<parameter property="PostalCode" />
</parameterMap>
- <parameterMap id="params-parent"> <!-- 1043181 support request -->
+ <parameterMap id="params-parent" class="Order"> <!-- 1043181 support request -->
<parameter property="Id" dbType="Int"/>
<parameter property="Account.Id"/>
<parameter property="Date" nullValue="01/01/0001 00:00:00" />
@@ -515,7 +515,7 @@
<parameter property="PostalCode" />
</parameterMap>
- <parameterMap id="insert-extend" extends="params-parent">
+ <parameterMap id="insert-extend" extends="params-parent" class="Order">
</parameterMap>
</parameterMaps>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml Wed Mar 29 08:15:54 2006
@@ -160,7 +160,7 @@
</statements>
<parameterMaps>
- <parameterMap id="insert-params">
+ <parameterMap id="insert-params" class="Other" >
<parameter property="Int" />
<parameter property="Long" />
<parameter property="Bool" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs Wed Mar 29 08:15:54 2006
@@ -325,7 +325,7 @@
try
{
IMappedStatement statement = _sqlMap.GetMappedStatement( _statementName );
- IDalSession session = new SqlMapSession(sqlMap.DataSource);
+ IDalSession session = new SqlMapSession(sqlMap);
session.OpenConnection();
IList list = statement.ExecuteQueryForList(session, null);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs Wed Mar 29 08:15:54 2006
@@ -92,7 +92,7 @@
map.Add("Name", "Toto");
map.Add("Guid", Guid.NewGuid());
- sqlMap.Insert("InsertCategoryViaStoreProcedure", map);
+ sqlMap.Insert("InsertCategoryViaStoreProcedureWithMap", map);
Assert.AreEqual(1, map["Id"] );
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Wed Mar 29 08:15:54 2006
@@ -9,6 +9,7 @@
<setting useStatementNamespaces="${useStatementNamespaces}"/>
<setting cacheModelsEnabled="true"/>
<setting validateSqlMap="false"/>
+ <setting useReflectionOptimizer="true"/>
</settings>
<!-- Optional if resource -->
<providers resource="providers.config"/>
@@ -43,6 +44,6 @@
<sqlMap resource="../../Maps/MSSQL/SqlClient/Document.xml"/>
<sqlMap resource="../../Maps/MSSQL/SqlClient/EmbedParameter.xml"/>
<sqlMap resource="../../Maps/MSSQL/SqlClient/Nullable.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/Simple.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/Simple.xml"/>
</sqlMaps>
</sqlMapConfig>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt Wed Mar 29 08:15:54 2006
@@ -3,6 +3,8 @@
------------------------------
1.4 - XX/XX/XXX
------------------------------
+- Added useReflectionOptimizer attribut setting in SqlMap.config
+- Added class attribute to parameterMap tags [it is required !]
- Added support for readOnly & serialize attribut on CacheModel
- Added Support for nullable type in .NET V2
- Added Support for .NET V2 and Generic
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs Wed Mar 29 08:15:54 2006
@@ -25,18 +25,20 @@
#endregion
#region Using
+
+using System;
+using System.Collections.Specialized;
using System.Data;
-using System.Collections;
+using System.Reflection;
using System.Text;
-using IBatisNet.Common.Logging;
-
using IBatisNet.Common;
+using IBatisNet.Common.Logging;
using IBatisNet.Common.Utilities.Objects;
-
-using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
+using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.Scope;
+
#endregion
namespace IBatisNet.DataMapper.Commands
@@ -48,7 +50,7 @@
{
#region Fields
- private static readonly ILog _logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
+ private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
private StringBuilder _paramLogList = new StringBuilder(); // Log info
private StringBuilder _typeLogList = new StringBuilder(); // Log info
@@ -95,13 +97,13 @@
( IDalSession session, IDbCommand command,
RequestScope request, IStatement statement, object parameterObject )
{
- ArrayList properties = request.PreparedStatement.DbParametersName;
- ArrayList parameters = request.PreparedStatement.DbParameters;
+ StringCollection properties = request.PreparedStatement.DbParametersName;
+ IDataParameter[] parameters = request.PreparedStatement.DbParameters;
int count = properties.Count;
for ( int i = 0; i < count; ++i )
{
- IDataParameter sqlParameter = (IDataParameter)parameters[i];
+ IDataParameter sqlParameter = parameters[i];
IDataParameter parameterCopy = command.CreateParameter();
ParameterProperty property = request.ParameterMap.GetProperty(i);
@@ -164,8 +166,8 @@
request.ParameterMap.GetProperty(i).DbType.Length >0)
{
string dbTypePropertyName = session.DataSource.DbProvider.ParameterDbTypeProperty;
-
- ObjectProbe.SetPropertyValue(parameterCopy, dbTypePropertyName, ObjectProbe.GetPropertyValue(sqlParameter, dbTypePropertyName));
+ object propertyValue = ObjectProbe.GetPropertyValue(sqlParameter, dbTypePropertyName);
+ ObjectProbe.SetPropertyValue(parameterCopy, dbTypePropertyName, propertyValue);
}
else
{
@@ -181,7 +183,7 @@
#region Logging
if (_logger.IsDebugEnabled)
{
- if (parameterCopy.Value == System.DBNull.Value)
+ if (parameterCopy.Value == DBNull.Value)
{
_paramLogList.Append("null");
_paramLogList.Append("], ");
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Wed Mar 29 08:15:54 2006
@@ -275,9 +275,9 @@
/// </summary>
private const string ATR_VALIDATE_SQLMAP = "validateSqlMap";
/// <summary>
- /// Token for embedStatementParams attribute.
+ /// Token for useReflectionOptimizer attribute.
/// </summary>
- private const string ATR_EMBED_STATEMENT_PARAMS = "useEmbedStatementParams";
+ private const string ATR_USE_REFLECTION_OPTIMIZER = "useReflectionOptimizer";
#endregion
@@ -299,7 +299,7 @@
public DomSqlMapBuilder()
{
_configScope = new ConfigurationScope();
- _paramParser = new InlineParameterMapParser( _configScope.ErrorContext );
+ _paramParser = new InlineParameterMapParser();
_deSerializerFactory = new DeSerializerFactory(_configScope);
}
@@ -317,7 +317,7 @@
_configScope = new ConfigurationScope();
_configScope.ValidateSqlMapConfig = validateSqlMapConfig;
_deSerializerFactory = new DeSerializerFactory(_configScope);
- _paramParser = new InlineParameterMapParser( _configScope.ErrorContext );
+ _paramParser = new InlineParameterMapParser();
}
#endregion
@@ -651,24 +651,6 @@
{
Reset();
- // To do, analyse config file to set allowCodeGeneration on object factory
- _configScope.SqlMapper = new SqlMapper( new ObjectFactory(true), new TypeHandlerFactory() , new MemberAccessorFactory(true) );
-
-
- #region Cache Alias
-
- TypeAlias cacheAlias = new TypeAlias(typeof(MemoryCacheControler));
- cacheAlias.Name = "MEMORY";
- _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
- cacheAlias = new TypeAlias(typeof(LruCacheController));
- cacheAlias.Name = "LRU";
- _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
- cacheAlias = new TypeAlias(typeof(FifoCacheController));
- cacheAlias.Name = "FIFO";
- _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
-
- #endregion
-
#region Load Global Properties
if (_configScope.IsCallFromDao == false)
{
@@ -683,7 +665,6 @@
_configScope.ErrorContext.Activity = "loading global settings";
XmlNodeList settings = _configScope.SqlMapConfigDocument.SelectNodes( ApplyDataMapperNamespacePrefix(XML_CONFIG_SETTINGS), _configScope.XmlNamespaceManager);
- //XML_CONFIG_SETTINGS);
if (settings!=null)
{
@@ -699,12 +680,11 @@
string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_CACHE_MODELS_ENABLED].Value, _configScope.Properties);
_configScope.IsCacheModelsEnabled = Convert.ToBoolean( value );
}
- if (setting.Attributes[ATR_EMBED_STATEMENT_PARAMS] != null )
+ if (setting.Attributes[ATR_USE_REFLECTION_OPTIMIZER] != null )
{
- string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_EMBED_STATEMENT_PARAMS].Value, _configScope.Properties);
- _configScope.UseEmbedStatementParams = Convert.ToBoolean( value );
+ string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_USE_REFLECTION_OPTIMIZER].Value, _configScope.Properties);
+ _configScope.UseReflectionOptimizer = Convert.ToBoolean( value );
}
-
if (setting.Attributes[ATR_VALIDATE_SQLMAP] != null )
{
string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_VALIDATE_SQLMAP].Value, _configScope.Properties);
@@ -713,10 +693,24 @@
}
}
- _configScope.SqlMapper.SetCacheModelsEnabled(_configScope.IsCacheModelsEnabled);
- _configScope.SqlMapper.SetUseEmbedStatementParams(_configScope.UseEmbedStatementParams);
+ #endregion
+
+ _configScope.SqlMapper = new SqlMapper( _configScope.UseReflectionOptimizer, new TypeHandlerFactory() );
+ _configScope.SqlMapper.CacheModelsEnabled =_configScope.IsCacheModelsEnabled;
- #endregion
+ #region Cache Alias
+
+ TypeAlias cacheAlias = new TypeAlias(typeof(MemoryCacheControler));
+ cacheAlias.Name = "MEMORY";
+ _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
+ cacheAlias = new TypeAlias(typeof(LruCacheController));
+ cacheAlias.Name = "LRU";
+ _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
+ cacheAlias = new TypeAlias(typeof(FifoCacheController));
+ cacheAlias.Name = "FIFO";
+ _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
+
+ #endregion
#region Load providers
if (_configScope.IsCallFromDao == false)
@@ -1112,7 +1106,7 @@
if (select.Generate != null)
{
- GenerateCommandText(_configScope.SqlMapper, select);
+ GenerateCommandText(_configScope, select);
}
else
{
@@ -1156,7 +1150,7 @@
// Build ISql (analyse sql command text)
if (insert.Generate != null)
{
- GenerateCommandText(_configScope.SqlMapper, insert);
+ GenerateCommandText(_configScope, insert);
}
else
{
@@ -1183,8 +1177,8 @@
string commandText = xmlNode.SelectSingleNode( ApplyMappingNamespacePrefix(XML_SELECTKEY), _configScope.XmlNamespaceManager).FirstChild.InnerText.Replace('\n', ' ').Replace('\r', ' ').Replace('\t', ' ').Trim();
commandText = NodeUtils.ParsePropertyTokens(commandText, _configScope.Properties);
- StaticSql sql = new StaticSql(insert.SelectKey);
- IDalSession session = new SqlMapSession( _configScope.SqlMapper.DataSource );
+ StaticSql sql = new StaticSql(_configScope, insert.SelectKey);
+ IDalSession session = new SqlMapSession( _configScope.SqlMapper );
sql.BuildPreparedStatement( session, commandText );
insert.SelectKey.Sql = sql;
@@ -1221,7 +1215,7 @@
// Build ISql (analyse sql statement)
if (update.Generate != null)
{
- GenerateCommandText(_configScope.SqlMapper, update);
+ GenerateCommandText(_configScope, update);
}
else
{
@@ -1259,7 +1253,7 @@
// Build ISql (analyse sql statement)
if (delete.Generate != null)
{
- GenerateCommandText(_configScope.SqlMapper, delete);
+ GenerateCommandText(_configScope, delete);
}
else
{
@@ -1387,7 +1381,7 @@
_configScope.ErrorContext.MoreInfo = "parse dynamic tags on sql statement";
- isDynamic = ParseDynamicTags( commandTextNode, dynamic, sqlBuffer, isDynamic, false);
+ isDynamic = ParseDynamicTags( commandTextNode, dynamic, sqlBuffer, isDynamic, false, statement);
if (isDynamic)
{
@@ -1411,7 +1405,7 @@
/// <param name="postParseRequired"></param>
/// <returns></returns>
private bool ParseDynamicTags( XmlNode commandTextNode, IDynamicParent dynamic,
- StringBuilder sqlBuffer, bool isDynamic, bool postParseRequired)
+ StringBuilder sqlBuffer, bool isDynamic, bool postParseRequired, IStatement statement)
{
XmlNodeList children = commandTextNode.ChildNodes;
int count = children.Count;
@@ -1432,7 +1426,7 @@
}
else
{
- sqlText = _paramParser.ParseInlineParameterMap(_configScope.TypeHandlerFactory, null, data );
+ sqlText = _paramParser.ParseInlineParameterMap(_configScope, statement, data );
}
dynamic.AddChild(sqlText);
@@ -1454,7 +1448,7 @@
if (child.HasChildNodes == true)
{
- isDynamic = ParseDynamicTags( child, tag, sqlBuffer, isDynamic, tag.Handler.IsPostParseRequired );
+ isDynamic = ParseDynamicTags( child, tag, sqlBuffer, isDynamic, tag.Handler.IsPostParseRequired, statement );
}
}
}
@@ -1483,12 +1477,17 @@
// Build a Parametermap with the inline parameters.
// if they exist. Then delete inline infos from sqltext.
- SqlText sqlText = _paramParser.ParseInlineParameterMap(_configScope.TypeHandlerFactory, statement, newSql );
+ SqlText sqlText = _paramParser.ParseInlineParameterMap(_configScope, statement, newSql );
if (sqlText.Parameters.Length > 0)
{
- ParameterMap map = new ParameterMap(_configScope.DataSource.DbProvider.UsePositionalParameters);
+ ParameterMap map = new ParameterMap();
map.Id = statement.Id + "-InLineParameterMap";
+ if (statement.ParameterClass!=null)
+ {
+ map.Class = statement.ParameterClass;
+ }
+ map.Initialize(_configScope.DataSource.DbProvider.UsePositionalParameters,_configScope);
statement.ParameterMap = map;
int lenght = sqlText.Parameters.Length;
@@ -1506,21 +1505,21 @@
if (SimpleDynamicSql.IsSimpleDynamicSql(newSql))
{
- sql = new SimpleDynamicSql(_configScope.TypeHandlerFactory, newSql, statement);
+ sql = new SimpleDynamicSql(_configScope, newSql, statement);
}
else
{
if (statement is Procedure)
{
- sql = new ProcedureSql(newSql, statement);
+ sql = new ProcedureSql(_configScope, newSql, statement);
// Could not call BuildPreparedStatement for procedure because when NUnit Test
// the database is not here (but in theory procedure must be prepared like statement)
// It's even better as we can then switch DataSource.
}
else if (statement is Statement)
{
- sql = new StaticSql(statement);
- IDalSession session = new SqlMapSession(_configScope.SqlMapper.DataSource);
+ sql = new StaticSql(_configScope, statement);
+ IDalSession session = new SqlMapSession(_configScope.SqlMapper);
((StaticSql)sql).BuildPreparedStatement( session, newSql );
}
@@ -1593,17 +1592,17 @@
/// <summary>
/// Generate the command text for CRUD operation
/// </summary>
- /// <param name="sqlMap"></param>
+ /// <param name="configScope"></param>
/// <param name="statement"></param>
- private void GenerateCommandText(SqlMapper sqlMap, IStatement statement)
+ private void GenerateCommandText(ConfigurationScope configScope, IStatement statement)
{
string generatedSQL = string.Empty;
//------ Build SQL CommandText
generatedSQL = SqlGenerator.BuildQuery(statement);
- ISql sql = new StaticSql(statement);
- IDalSession session = new SqlMapSession(sqlMap.DataSource);
+ ISql sql = new StaticSql(configScope, statement);
+ IDalSession session = new SqlMapSession(configScope.SqlMapper);
((StaticSql)sql).BuildPreparedStatement( session, generatedSQL );
statement.Sql = sql;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs Wed Mar 29 08:15:54 2006
@@ -1,7 +1,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -52,8 +52,6 @@
private const string PARAMETER_TOKEN = "#";
private const string PARAM_DELIM = ":";
- private ErrorContext _errorContext= null;
-
#endregion
#region Constructors
@@ -61,10 +59,8 @@
/// <summary>
/// Constructor
/// </summary>
- /// <param name="errorContext"></param>
- public InlineParameterMapParser(ErrorContext errorContext)
+ public InlineParameterMapParser()
{
- _errorContext = errorContext;
}
#endregion
@@ -74,8 +70,8 @@
/// <param name="statement"></param>
/// <param name="sqlStatement"></param>
/// <returns>A new sql command text.</returns>
- /// <param name="typeHandlerFactory"></param>
- public SqlText ParseInlineParameterMap(TypeHandlerFactory typeHandlerFactory, IStatement statement, string sqlStatement)
+ /// <param name="scope"></param>
+ public SqlText ParseInlineParameterMap(IScope scope, IStatement statement, string sqlStatement)
{
string newSql = sqlStatement;
ArrayList mappingList = new ArrayList();
@@ -110,11 +106,11 @@
ParameterProperty mapping = null;
if (token.IndexOf(PARAM_DELIM) > -1)
{
- mapping = OldParseMapping(token, parameterClassType, typeHandlerFactory);
+ mapping = OldParseMapping(token, parameterClassType, scope);
}
else
{
- mapping = NewParseMapping(token, parameterClassType, typeHandlerFactory);
+ mapping = NewParseMapping(token, parameterClassType, scope);
}
mappingList.Add(mapping);
@@ -158,9 +154,9 @@
/// </summary>
/// <param name="token"></param>
/// <param name="parameterClassType"></param>
- /// <param name="typeHandlerFactory"></param>
+ /// <param name="scope"></param>
/// <returns></returns>
- private ParameterProperty NewParseMapping(string token, Type parameterClassType, TypeHandlerFactory typeHandlerFactory)
+ private ParameterProperty NewParseMapping(string token, Type parameterClassType, IScope scope)
{
ParameterProperty mapping = new ParameterProperty();
@@ -210,23 +206,23 @@
if (mapping.CallBackName.Length >0)
{
- mapping.Initialize( typeHandlerFactory, _errorContext );
+ mapping.Initialize( scope, parameterClassType );
}
else
{
ITypeHandler handler = null;
if (parameterClassType == null)
{
- handler = typeHandlerFactory.GetUnkownTypeHandler();
+ handler = scope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(typeHandlerFactory,
+ handler = ResolveTypeHandler( scope.TypeHandlerFactory,
parameterClassType, mapping.PropertyName,
mapping.CLRType, mapping.DbType );
}
mapping.TypeHandler = handler;
- mapping.Initialize( typeHandlerFactory, _errorContext );
+ mapping.Initialize( scope, parameterClassType );
}
return mapping;
@@ -239,9 +235,9 @@
/// </summary>
/// <param name="token"></param>
/// <param name="parameterClassType"></param>
- /// <param name="typeHandlerFactory"></param>
+ /// <param name="scope"></param>
/// <returns></returns>
- private ParameterProperty OldParseMapping(string token, Type parameterClassType, TypeHandlerFactory typeHandlerFactory)
+ private ParameterProperty OldParseMapping(string token, Type parameterClassType, IScope scope)
{
ParameterProperty mapping = new ParameterProperty();
@@ -265,14 +261,14 @@
ITypeHandler handler = null;
if (parameterClassType == null)
{
- handler = typeHandlerFactory.GetUnkownTypeHandler();
+ handler = scope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(typeHandlerFactory, parameterClassType, propertyName, null, dBType);
+ handler = ResolveTypeHandler(scope.TypeHandlerFactory, parameterClassType, propertyName, null, dBType);
}
mapping.TypeHandler = handler;
- mapping.Initialize( typeHandlerFactory, _errorContext );
+ mapping.Initialize( scope, parameterClassType );
}
else if (n1 >= 5)
{
@@ -295,14 +291,14 @@
ITypeHandler handler = null;
if (parameterClassType == null)
{
- handler = typeHandlerFactory.GetUnkownTypeHandler();
+ handler = scope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(typeHandlerFactory, parameterClassType, propertyName, null, dBType);
+ handler = ResolveTypeHandler(scope.TypeHandlerFactory, parameterClassType, propertyName, null, dBType);
}
mapping.TypeHandler = handler;
- mapping.Initialize( typeHandlerFactory, _errorContext );
+ mapping.Initialize( scope, parameterClassType );
}
else
{
@@ -315,14 +311,14 @@
ITypeHandler handler = null;
if (parameterClassType == null)
{
- handler = typeHandlerFactory.GetUnkownTypeHandler();
+ handler = scope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(typeHandlerFactory, parameterClassType, token, null, null);
+ handler = ResolveTypeHandler(scope.TypeHandlerFactory, parameterClassType, token, null, null);
}
mapping.TypeHandler = handler;
- mapping.Initialize( typeHandlerFactory, _errorContext );
+ mapping.Initialize( scope, parameterClassType );
}
return mapping;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -31,6 +31,7 @@
using System.Data;
using System.Xml;
using System.Xml.Serialization;
+using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.Configuration.Serializers;
using IBatisNet.DataMapper.Scope;
@@ -47,7 +48,6 @@
[XmlRoot("parameterMap", Namespace="http://ibatis.apache.org/mapping")]
public class ParameterMap
{
-
/// <summary>
/// Token for xml path to parameter elements.
/// </summary>
@@ -57,11 +57,11 @@
[NonSerialized]
private string _id = string.Empty;
[NonSerialized]
- // Properties list
- private ArrayList _properties = new ArrayList();
+ // Properties list
+ private ParameterPropertyCollection _properties = new ParameterPropertyCollection();
// Same list as _properties but without doubled (Test UpdateAccountViaParameterMap2)
[NonSerialized]
- private ArrayList _propertiesList = new ArrayList();
+ private ParameterPropertyCollection _propertiesList = new ParameterPropertyCollection();
//(property Name, property)
[NonSerialized]
private Hashtable _propertiesMap = new Hashtable(); // Corrected ?? Support Request 1043181, move to HashTable
@@ -69,19 +69,54 @@
private string _extendMap = string.Empty;
[NonSerialized]
private bool _usePositionalParameters =false;
-
+ [NonSerialized]
+ private string _className = string.Empty;
+ [NonSerialized]
+ private Type _class = null;
#endregion
#region Properties
/// <summary>
+ /// The parameter class name.
+ /// </summary>
+ [XmlAttribute("class")]
+ public string ClassName
+ {
+ get { return _className; }
+ set
+ {
+ if ((value == null) || (value.Length < 1))
+ throw new ArgumentNullException("The class attribute is mandatory in a ParameterMap tag '"+_id+"'.");
+
+ _className = value;
+ }
+ }
+
+ /// <summary>
+ /// The parameter type class.
+ /// </summary>
+ [XmlIgnore]
+ public Type Class
+ {
+ set { _class = value; }
+ get { return _class; }
+ }
+
+ /// <summary>
/// Identifier used to identify the ParameterMap amongst the others.
/// </summary>
[XmlAttribute("id")]
public string Id
{
get { return _id; }
- set { _id = value; }
+ set
+ {
+ if ((value == null) || (value.Length < 1))
+ throw new ArgumentNullException("The id attribute is mandatory in a ParameterMap tag.");
+
+ _id = value;
+ }
}
@@ -89,27 +124,16 @@
/// The collection of ParameterProperty
/// </summary>
[XmlIgnore]
- public ArrayList Properties
+ public ParameterPropertyCollection Properties
{
- get
- {
- // if (_usePositionalParameters) //obdc/oledb
- // {
- // return _properties;
- // }
- // else
- // {
- // return _propertiesList;
- // }
- return _properties;
- }
+ get { return _properties; }
}
/// <summary>
///
/// </summary>
[XmlIgnore]
- public ArrayList PropertiesList
+ public ParameterPropertyCollection PropertiesList
{
get { return _propertiesList; }
}
@@ -134,15 +158,6 @@
public ParameterMap()
{}
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <param name="usePositionalParameters"></param>
- public ParameterMap(bool usePositionalParameters)
- {
- _usePositionalParameters = usePositionalParameters;
-
- }
#endregion
#region Methods
@@ -155,13 +170,12 @@
{
if (_usePositionalParameters) //obdc/oledb
{
- return (ParameterProperty)_properties[index];
+ return _properties[index];
}
else
{
- return (ParameterProperty)_propertiesList[index];
+ return _propertiesList[index];
}
- //return (ParameterProperty)_properties[index];
}
/// <summary>
@@ -256,27 +270,42 @@
{
object value = parameterValue;
ITypeHandler typeHandler = mapping.TypeHandler;
+ Type parameterType = parameterValue.GetType();
// "The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32,
// UInt32, Int64, UInt64, Char, Double, and Single."
- if (parameterValue.GetType() != typeof(string) &&
- parameterValue.GetType() != typeof(Guid) &&
- parameterValue.GetType() != typeof(Decimal) &&
- parameterValue.GetType() != typeof(DateTime) &&
- !parameterValue.GetType().IsPrimitive)
- {
- value = ObjectProbe.GetPropertyValue(value, mapping.PropertyName);
+ // To Do impelement something like DataExchange as Java
- // This code is obsolete
- // if we realy need it we must put it in the SetParameter method
- // of theByteArrayTypeHandler
-// if (value != null && value.GetType() == typeof(byte[]))
-// {
-// MemoryStream stream = new MemoryStream((byte[])value);
-//
-// value = stream.ToArray();
-// }
+ if (parameterType != typeof(string) &&
+ parameterType != typeof(Guid) &&
+ parameterType != typeof(Decimal) &&
+ parameterType != typeof(DateTime) &&
+ !parameterType.IsPrimitive)
+ {
+ if (typeof(IDictionary).IsAssignableFrom(parameterType) || typeof(IList).IsAssignableFrom(parameterType) || mapping.IsComplexMemberName)
+ {
+ value = ObjectProbe.GetPropertyValue(value, mapping.PropertyName);
+ }
+ else
+ {
+ if (_class == null || _class!=parameterValue.GetType())
+ {
+ value = ObjectProbe.GetPropertyValue(value, mapping.PropertyName);
+ }
+ else
+ {
+ if (mapping.MemberAccessor!=null)
+ {
+ value = mapping.MemberAccessor.Get(value);
+ }
+ else
+ {
+ //Dynamic Iterate Id[0]
+ value = ObjectProbe.GetPropertyValue(value, mapping.PropertyName);
+ }
+ }
+ }
}
// Apply Null Value
@@ -288,36 +317,38 @@
}
}
- // Set Parameter
- if (value != null)
- {
- typeHandler.SetParameter(dataParameter, value, mapping.DbType);
- }
- else if(typeHandler is CustomTypeHandler)
- {
- typeHandler.SetParameter(dataParameter, value, mapping.DbType);
- }
- else
- {
- // When sending a null parameter value to the server,
- // the user must specify DBNull, not null.
- dataParameter.Value = DBNull.Value;
- }
+
+ typeHandler.SetParameter(dataParameter, value, mapping.DbType);
}
+
#region Configuration
+
/// <summary>
/// Initialize the parameter properties child.
/// </summary>
- /// <param name="configScope"></param>
- public void Initialize(ConfigurationScope configScope)
+ /// <param name="scope"></param>
+ /// <param name="usePositionalParameters"></param>
+ public void Initialize(bool usePositionalParameters, IScope scope)
{
- _usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters;
- GetProperties( configScope );
+ _usePositionalParameters = usePositionalParameters;
+ if (_className.Length>0 )
+ {
+ _class = scope.TypeHandlerFactory.GetType(_className);
+ }
}
/// <summary>
+ /// Build the properties
+ /// </summary>
+ /// <param name="scope"></param>
+ public void BuildProperties(ConfigurationScope scope)
+ {
+ GetProperties( scope );
+ }
+
+ /// <summary>
/// Get the parameter properties child for the xmlNode parameter.
/// </summary>
/// <param name="configScope"></param>
@@ -328,6 +359,9 @@
foreach ( XmlNode parameterNode in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_PARAMATER), configScope.XmlNamespaceManager) )
{
property = ParameterPropertyDeSerializer.Deserialize(parameterNode, configScope);
+
+ property.Initialize(configScope, _class);
+
AddParameterProperty(property);
}
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -27,11 +27,14 @@
#region Using
using System;
+using System.Collections;
using System.Data;
+using System.Reflection;
using System.Xml.Serialization;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities;
using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
@@ -51,7 +54,7 @@
[NonSerialized]
private string _nullValue = null;//string.Empty;//null;
[NonSerialized]
- private string _property = string.Empty;
+ private string _propertyName = string.Empty;
[NonSerialized]
private ParameterDirection _direction = ParameterDirection.Input;
[NonSerialized]
@@ -72,11 +75,24 @@
private string _clrType = string.Empty;
[NonSerialized]
private string _callBackName= string.Empty;
+ [NonSerialized]
+ private IMemberAccessor _memberAccessor = null;
+ [NonSerialized]
+ private bool _isComplexMemberName = false;
+
#endregion
#region Properties
/// <summary>
+ /// Indicate if we have a complex member name as [avouriteLineItem.Id]
+ /// </summary>
+ public bool IsComplexMemberName
+ {
+ get { return _isComplexMemberName; }
+ }
+
+ /// <summary>
/// Specify the custom type handlers to used.
/// </summary>
/// <remarks>Will be an alias to a class wchic implement ITypeHandlerCallback</remarks>
@@ -200,13 +216,21 @@
[XmlAttribute("property")]
public string PropertyName
{
- get { return _property; }
+ get { return _propertyName; }
set
{
if ((value == null) || (value.Length < 1))
throw new ArgumentNullException("The property attribute is mandatory in a paremeter property.");
- _property = value;
+ _propertyName = value;
+ if (_propertyName.IndexOf('.')<0)
+ {
+ _isComplexMemberName = false;
+ }
+ else // complex member name FavouriteLineItem.Id
+ {
+ _isComplexMemberName = true;
+ }
}
}
@@ -229,6 +253,15 @@
get { return _nullValue; }
set { _nullValue = value; }
}
+
+ /// <summary>
+ /// The IMemberAccessor
+ /// </summary>
+ [XmlIgnore]
+ public IMemberAccessor MemberAccessor
+ {
+ get { return _memberAccessor; }
+ }
#endregion
#region Constructor (s) / Destructor
@@ -243,23 +276,39 @@
#region Methods
/// <summary>
- ///
+ /// Initialize the parameter property
/// </summary>
- /// <param name="typeHandlerFactory"></param>
- /// <param name="errorContext"></param>
- public void Initialize(TypeHandlerFactory typeHandlerFactory, ErrorContext errorContext)
+ /// <param name="scope"></param>
+ /// <param name="parameterClass"></param>
+ public void Initialize(IScope scope, Type parameterClass)
{
if(_directionAttribute.Length >0)
{
_direction = (ParameterDirection)Enum.Parse( typeof(ParameterDirection), _directionAttribute, true );
}
-
- errorContext.MoreInfo = "Check the parameter mapping typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
+
+ if (!typeof(IDictionary).IsAssignableFrom(parameterClass) // Hashtable parameter map
+ && parameterClass !=null // value property
+ && !scope.TypeHandlerFactory.IsSimpleType(parameterClass) ) // value property
+ {
+ if (!_isComplexMemberName)
+ {
+ _memberAccessor = scope.MemberAccessorFactory.CreateMemberAccessor( parameterClass, _propertyName);
+ }
+ else // complex member name FavouriteLineItem.Id
+ {
+ PropertyInfo propertyInfo = ObjectProbe.GetPropertyInfoForSetter(parameterClass, _propertyName);
+ string memberName = _propertyName.Substring( _propertyName.LastIndexOf('.')+1);
+ _memberAccessor = scope.MemberAccessorFactory.CreateMemberAccessor( propertyInfo.ReflectedType, memberName);
+ }
+ }
+
+ scope.ErrorContext.MoreInfo = "Check the parameter mapping typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
if (this.CallBackName.Length >0)
{
try
{
- Type type = typeHandlerFactory.GetType(this.CallBackName);
+ Type type = scope.TypeHandlerFactory.GetType(this.CallBackName);
ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback) Activator.CreateInstance( type );
_typeHandler = new CustomTypeHandler(typeHandlerCallback);
}
@@ -272,45 +321,28 @@
{
if (this.CLRType.Length == 0 ) // Unknown
{
- _typeHandler = typeHandlerFactory.GetUnkownTypeHandler();
+ _typeHandler = scope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else // If we specify a CLR type, use it
{
Type type = Resources.TypeForName(this.CLRType);
- if (typeHandlerFactory.IsSimpleType(type))
+ if (scope.TypeHandlerFactory.IsSimpleType(type))
{
// Primitive
- _typeHandler = typeHandlerFactory.GetTypeHandler(type, _dbType);
+ _typeHandler = scope.TypeHandlerFactory.GetTypeHandler(type, _dbType);
}
else
{
// .NET object
type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
- _typeHandler = typeHandlerFactory.GetTypeHandler(type, _dbType);
+ _typeHandler = scope.TypeHandlerFactory.GetTypeHandler(type, _dbType);
}
}
}
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="errorContext"></param>
- internal void Initialize(ErrorContext errorContext)
- {
- errorContext.MoreInfo = "Initialize an inline parameter property '" + this.PropertyName + "' .";
-
- if(_directionAttribute.Length >0)
- {
- _direction = (ParameterDirection)Enum.Parse( typeof(ParameterDirection), _directionAttribute, true );
- }
-
-
-
- }
-
/// <summary>
///
@@ -331,7 +363,7 @@
/// <returns></returns>
public override int GetHashCode()
{
- return _property.GetHashCode();
+ return _propertyName.GetHashCode();
}
#endregion
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs?rev=389819&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs Wed Mar 29 08:15:54 2006
@@ -0,0 +1,133 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * 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.Collections;
+
+namespace IBatisNet.DataMapper.Configuration.ParameterMapping
+{
+ /// <summary>
+ /// A ParameterProperty Collection.
+ /// </summary>
+ public class ParameterPropertyCollection: CollectionBase
+ {
+ /// <summary>
+ /// Constructeur
+ /// </summary>
+ public ParameterPropertyCollection() {}
+
+
+ /// <summary>
+ /// Acces element in collection by index
+ /// </summary>
+ public ParameterProperty this[int index]
+ {
+ get { return (ParameterProperty)List[index]; }
+ set { List[index] = value; }
+ }
+
+ /// <summary>
+ /// Add an ParameterProperty
+ /// </summary>
+ /// <param name="value"></param>
+ public int Add(ParameterProperty value)
+ {
+ return List.Add(value);
+ }
+
+ /// <summary>
+ /// Add a list of ParameterProperty to the collection
+ /// </summary>
+ /// <param name="value"></param>
+ public void AddRange(ParameterProperty[] value)
+ {
+ for (int i = 0; i < value.Length; i++)
+ {
+ Add(value[i]);
+ }
+ }
+
+ /// <summary>
+ /// Add a list of ParameterProperty to the collection
+ /// </summary>
+ /// <param name="value"></param>
+ public void AddRange(ParameterPropertyCollection value)
+ {
+ for (int i = 0; i < value.Count; i++)
+ {
+ Add(value[i]);
+ }
+ }
+
+ /// <summary>
+ /// Indicate if a ParameterProperty is in the collection
+ /// </summary>
+ /// <param name="value">Un(e) ParameterProperty</param>
+ /// <returns>Renvoir vrai s'il/elle appartinet à la collection</returns>
+ public bool Contains(ParameterProperty value)
+ {
+ return List.Contains(value);
+ }
+
+
+ /// <summary>
+ /// Copy a collection in a ParameterProperty array
+ /// </summary>
+ /// <param name="array">A ParameterProperty array</param>
+ /// <param name="index">Start index of the copy</param>
+ public void CopyTo(ParameterProperty[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ /// <summary>
+ /// Position of the ParameterProperty in the collection.
+ /// </summary>
+ /// <param name="value">A ParameterProperty</param>
+ /// <returns>Index found.</returns>
+ public int IndexOf(ParameterProperty value)
+ {
+ return List.IndexOf(value);
+ }
+
+ /// <summary>
+ /// Insert a ParameterProperty in the collection.
+ /// </summary>
+ /// <param name="index">Index where to insert.</param>
+ /// <param name="value">A ParameterProperty</param>
+ public void Insert(int index, ParameterProperty value)
+ {
+ List.Insert(index, value);
+ }
+
+ /// <summary>
+ /// Remove a ParameterProperty of the collection.
+ /// </summary>
+ public void Remove(ParameterProperty value)
+ {
+ List.Remove(value);
+ }
+ }
+}
+
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Wed Mar 29 08:15:54 2006
@@ -63,7 +63,7 @@
/// </summary>
private const string XML_SUBMAP = "subMap";
- private IFactory _objectFactory = null;
+ private IFactory _objectFactory = null;
#region Fields
[NonSerialized]
@@ -284,7 +284,7 @@
if (typeCode == TypeCode.Object)
{
- return _objectFactory.CreateInstance();
+ return _objectFactory.CreateInstance();
}
else
{
@@ -320,9 +320,16 @@
throw new ArgumentException( "Could not set value of type '"+ target.GetType() +"' in property '"+property.PropertyName+"' of type '"+_class+"'" );
}
- if ( property.PropertyInfo != null )
+ if ( property.MemberAccessor != null )
{
- ObjectProbe.SetPropertyValue(target, property.PropertyName, dataBaseValue);
+ if (property.IsComplexMemberName)
+ {
+ ObjectProbe.SetPropertyValue(target, property.PropertyName, dataBaseValue);
+ }
+ else
+ {
+ property.MemberAccessor.Set(target, dataBaseValue);
+ }
}
else // Primitive type ('value')
{
@@ -338,7 +345,7 @@
/// <returns></returns>
public ResultMap ResolveSubMap(IDataReader dataReader)
{
- ResultMap subMap = this;
+ ResultMap subMap = this;
if (_discriminator != null)
{
ResultProperty mapping = _discriminator.ResultProperty;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs Wed Mar 29 08:15:54 2006
@@ -33,6 +33,7 @@
using System.Xml.Serialization;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
@@ -58,7 +59,7 @@
#region Fields
[NonSerialized]
- private PropertyInfo _propertyInfo = null;
+ private IMemberAccessor _memberAccessor = null;
[NonSerialized]
private string _nullValue = null;
[NonSerialized]
@@ -83,6 +84,8 @@
private ITypeHandler _typeHandler = null;
[NonSerialized]
private string _callBackName= string.Empty;
+ [NonSerialized]
+ private bool _isComplexMemberName = false;
#endregion
#region Properties
@@ -196,16 +199,27 @@
public string PropertyName
{
get { return _propertyName; }
- set { _propertyName = value; }
+ set
+ {
+ _propertyName = value;
+ if (_propertyName.IndexOf('.')<0)
+ {
+ _isComplexMemberName = false;
+ }
+ else // complex member name FavouriteLineItem.Id
+ {
+ _isComplexMemberName = true;
+ }
+ }
}
/// <summary>
///
/// </summary>
[XmlIgnore]
- public PropertyInfo PropertyInfo
+ public IMemberAccessor MemberAccessor
{
- get { return _propertyInfo; }
+ get { return _memberAccessor; }
}
/// <summary>
@@ -237,6 +251,15 @@
get { return _nestedResultMap; }
set { _nestedResultMap = value; }
}
+
+ /// <summary>
+ /// Indicate if we have a complex member name as [FavouriteLineItem.Id]
+ /// </summary>
+ public bool IsComplexMemberName
+ {
+ get { return _isComplexMemberName; }
+ }
+
#endregion
#region Constructor (s) / Destructor
@@ -257,9 +280,20 @@
/// <param name="configScope"></param>
public void Initialize( ConfigurationScope configScope, Type resultClass )
{
- if ( _propertyName.Length>0 &&_propertyName != "value" && !typeof(IDictionary).IsAssignableFrom(resultClass) )
+ if ( _propertyName.Length>0 &&
+ _propertyName != "value" &&
+ !typeof(IDictionary).IsAssignableFrom(resultClass) )
{
- _propertyInfo = ObjectProbe.GetPropertyInfoForSetter(resultClass, _propertyName);
+ if (!_isComplexMemberName)
+ {
+ _memberAccessor = configScope.MemberAccessorFactory.CreateMemberAccessor( resultClass, _propertyName);
+ }
+ else // complex member name FavouriteLineItem.Id
+ {
+ PropertyInfo propertyInfo = ObjectProbe.GetPropertyInfoForSetter(resultClass, _propertyName);
+ string memberName = _propertyName.Substring( _propertyName.LastIndexOf('.')+1);
+ _memberAccessor = configScope.MemberAccessorFactory.CreateMemberAccessor( propertyInfo.ReflectedType, memberName);
+ }
}
if (this.CallBackName!=null && this.CallBackName.Length >0)
@@ -287,13 +321,12 @@
/// Initialize the PropertyInfo of the result property
/// for AutoMapper
/// </summary>
- /// <param name="propertyInfo">A PropertyInfoot.</param>
+ /// <param name="memberAccessor">An IMemberAccessor.</param>
/// <param name="typeHandlerFactory"></param>
- internal void Initialize(TypeHandlerFactory typeHandlerFactory, PropertyInfo propertyInfo )
+ internal void Initialize(TypeHandlerFactory typeHandlerFactory, IMemberAccessor memberAccessor )
{
- _propertyInfo = propertyInfo;
-
- _typeHandler = typeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+ _memberAccessor = memberAccessor;
+ _typeHandler = typeHandlerFactory.GetTypeHandler(memberAccessor.MemberType);
}
/// <summary>
@@ -319,9 +352,9 @@
{
if (this.HasNullValue)
{
- if (_propertyInfo!=null)
+ if (_memberAccessor!=null)
{
- value = _typeHandler.ValueOf(_propertyInfo.PropertyType, _nullValue);
+ value = _typeHandler.ValueOf(_memberAccessor.MemberType, _nullValue);
}
else
{
@@ -330,29 +363,29 @@
}
else
{
- value = _typeHandler.NullValue;
+ value = _typeHandler.NullValue;
}
}
return value;
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="value"></param>
- /// <returns></returns>
- public object TranslateValue(object value)
- {
- if (value == null)
- {
- return _typeHandler.NullValue;
- }
- else
- {
- return value;
- }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="value"></param>
+ /// <returns></returns>
+ public object TranslateValue(object value)
+ {
+ if (value == null)
+ {
+ return _typeHandler.NullValue;
+ }
+ else
+ {
+ return value;
+ }
+ }
#endregion
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs Wed Mar 29 08:15:54 2006
@@ -1,7 +1,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -54,10 +54,12 @@
parameterMap.ExtendMap = NodeUtils.GetStringAttribute(prop, "extends");
parameterMap.Id = NodeUtils.GetStringAttribute(prop, "id");
+ parameterMap.ClassName = NodeUtils.GetStringAttribute(prop,"class");
configScope.ErrorContext.MoreInfo = "Initialize ParameterMap";
configScope.NodeContext = node;
- parameterMap.Initialize( configScope );
+ parameterMap.Initialize( configScope.DataSource.DbProvider.UsePositionalParameters, configScope );
+ parameterMap.BuildProperties(configScope);
configScope.ErrorContext.MoreInfo = string.Empty;
return parameterMap;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs Wed Mar 29 08:15:54 2006
@@ -1,7 +1,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -62,8 +62,6 @@
property.Precision = NodeUtils.GetByteAttribute(prop, "precision", 0);
property.Scale = NodeUtils.GetByteAttribute(prop, "scale", 0);
property.Size = NodeUtils.GetIntAttribute(prop, "size", -1);
-
- property.Initialize(configScope.TypeHandlerFactory, configScope.ErrorContext);
return property;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -29,6 +29,7 @@
using System.Collections;
using System.Text;
using IBatisNet.Common;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Handlers;
@@ -56,6 +57,7 @@
private IStatement _statement = null ;
private InlineParameterMapParser _paramParser = null;
private TypeHandlerFactory _typeHandlerFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
private bool _usePositionalParameters = false;
#endregion
@@ -70,6 +72,7 @@
{
_statement = statement;
_typeHandlerFactory = configScope.TypeHandlerFactory;
+ _memberAccessorFactory = configScope.MemberAccessorFactory;
_usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters;
}
#endregion
@@ -99,8 +102,8 @@
/// <returns></returns>
public RequestScope GetRequestScope(object parameterObject, IDalSession session)
{
- RequestScope request = new RequestScope();
- _paramParser = new InlineParameterMapParser( request.ErrorContext );
+ RequestScope request = new RequestScope(_typeHandlerFactory, _memberAccessorFactory);
+ _paramParser = new InlineParameterMapParser();
request.ResultMap = _statement.ResultMap;
string sqlStatement = Process(request, parameterObject);
@@ -126,8 +129,10 @@
ProcessBodyChildren(request, ctx, parameterObject, localChildren);
// Builds a 'dynamic' ParameterMap
- ParameterMap map = new ParameterMap(_usePositionalParameters);
+ ParameterMap map = new ParameterMap();
map.Id = _statement.Id + "-InlineParameterMap";
+ map.Initialize(_usePositionalParameters, request);
+ map.Class = _statement.ParameterClass;
// Adds 'dynamic' ParameterProperty
IList parameters = ctx.GetParameterMappings();
@@ -143,7 +148,7 @@
// Processes $substitutions$ after DynamicSql
if ( SimpleDynamicSql.IsSimpleDynamicSql(dynSql) )
{
- dynSql = new SimpleDynamicSql(_typeHandlerFactory, dynSql, _statement).GetSql(parameterObject);
+ dynSql = new SimpleDynamicSql(request, dynSql, _statement).GetSql(parameterObject);
}
return dynSql;
}
@@ -251,7 +256,7 @@
if (handler.IsPostParseRequired)
{
- SqlText sqlText = _paramParser.ParseInlineParameterMap(_typeHandlerFactory, null, body.ToString() );
+ SqlText sqlText = _paramParser.ParseInlineParameterMap(request, null, body.ToString() );
buffer.Append(sqlText.Text);
ParameterProperty[] mappings = sqlText.Parameters;
if (mappings != null)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -25,11 +25,12 @@
#endregion
#region Imports
-using System;
+
using System.Collections;
using System.Text;
using IBatisNet.Common;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Configuration.Sql;
using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.Scope;
@@ -55,6 +56,7 @@
private string _simpleSqlStatement = string.Empty;
private IStatement _statement = null ;
private TypeHandlerFactory _typeHandlerFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
#endregion
@@ -64,12 +66,15 @@
/// </summary>
/// <param name="sqlStatement">The sql statement.</param>
/// <param name="statement"></param>
- /// <param name="typeHandlerFactory"></param>
- internal SimpleDynamicSql(TypeHandlerFactory typeHandlerFactory,string sqlStatement, IStatement statement)
+ /// <param name="scope"></param>
+ internal SimpleDynamicSql(IScope scope,
+ string sqlStatement,
+ IStatement statement)
{
_simpleSqlStatement = sqlStatement;
_statement = statement;
- _typeHandlerFactory = typeHandlerFactory;
+ _typeHandlerFactory = scope.TypeHandlerFactory;
+ _memberAccessorFactory = scope.MemberAccessorFactory;
}
#endregion
@@ -103,7 +108,6 @@
private string ProcessDynamicElements(object parameterObject)
{
// define which character is seperating fields
- char[] splitter = ELEMENT_TOKEN.ToCharArray();
StringTokenizer parser = new StringTokenizer(_simpleSqlStatement, ELEMENT_TOKEN, true);
@@ -181,7 +185,7 @@
{
string sqlStatement = ProcessDynamicElements(parameterObject);
- RequestScope request = new RequestScope();
+ RequestScope request = new RequestScope(_typeHandlerFactory, _memberAccessorFactory);
request.ParameterMap = _statement.ParameterMap;
request.ResultMap = _statement.ResultMap;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/ProcedureSql.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/ProcedureSql.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/ProcedureSql.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/ProcedureSql.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -28,8 +28,11 @@
using System;
using IBatisNet.Common;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.Scope;
+using IBatisNet.DataMapper.TypeHandlers;
+
#endregion
@@ -46,6 +49,8 @@
private PreparedStatement _preparedStatement = null ;
private string _sqlStatement = string.Empty;
private object _synRoot = new Object();
+ private TypeHandlerFactory _typeHandlerFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
#endregion
@@ -55,10 +60,13 @@
/// </summary>
/// <param name="statement">The statement.</param>
/// <param name="sqlStatement"></param>
- public ProcedureSql(string sqlStatement, IStatement statement)
+ /// <param name="scope"></param>
+ public ProcedureSql(IScope scope, string sqlStatement, IStatement statement)
{
_sqlStatement = sqlStatement;
_statement = statement;
+ _typeHandlerFactory = scope.TypeHandlerFactory;
+ _memberAccessorFactory = scope.MemberAccessorFactory;
}
#endregion
@@ -72,7 +80,7 @@
/// <returns></returns>
public RequestScope GetRequestScope(object parameterObject, IDalSession session)
{
- RequestScope request = new RequestScope();
+ RequestScope request = new RequestScope(_typeHandlerFactory, _memberAccessorFactory);
request.ParameterMap = _statement.ParameterMap;
request.ResultMap = _statement.ResultMap;