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 2005/05/08 18:20:33 UTC
svn commit: r169140 [1/2] -
/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler
Author: gbayon
Date: Sun May 8 09:20:30 2005
New Revision: 169140
URL: http://svn.apache.org/viewcvs?rev=169140&view=rev
Log:
- Added custom type handler support (I have updated Oracle script but not run them)
Added:
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CustomTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandlerCallback.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetter.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetterImpl.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetter.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetterImpl.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/UnknownTypeHandler.cs
Modified:
incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions/ConfigurationException.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Other.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/other-init.sql
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql/other-init.sql
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle/other-init.sql
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/InlineParameterMapParser.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterMap.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterProperty.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BaseTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BooleanTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteArrayTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CharTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DateTimeTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DecimalTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DoubleTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/EnumTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/GuidTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int16TypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int32TypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int64TypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ObjectTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/SingleTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/StringTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TimeSpanTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TypeHandlerFactory.cs
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions/ConfigurationException.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions/ConfigurationException.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions/ConfigurationException.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions/ConfigurationException.cs Sun May 8 09:20:30 2005
@@ -24,8 +24,13 @@
********************************************************************************/
#endregion
+#region Using
+
using System;
using System.Runtime.Serialization;
+#endregion
+
+
namespace IBatisNet.Common.Exceptions
{
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Other.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Other.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Other.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Other.cs Sun May 8 09:20:30 2005
@@ -1,50 +1,37 @@
-using System;
-
namespace IBatisNet.DataMapper.Test.Domain
{
/// <summary>
- /// Description résumée de Other.
+ /// Other.
/// </summary>
public class Other
{
private int _int;
private long _long;
private bool _bool = false;
+ private bool _bool2 = false;
+
+ public bool Bool2
+ {
+ get { return _bool2; }
+ set { _bool2 = value; }
+ }
public bool Bool
{
- get
- {
- return _bool;
- }
- set
- {
- _bool = value;
- }
+ get { return _bool; }
+ set { _bool = value; }
}
public int Int
{
- get
- {
- return _int;
- }
- set
- {
- _int = value;
- }
+ get { return _int; }
+ set { _int = value; }
}
public long Long
{
- get
- {
- return _long;
- }
- set
- {
- _long = value;
- }
+ get { return _long; }
+ set { _long = value; }
}
}
}
Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs Sun May 8 09:20:30 2005
@@ -0,0 +1,65 @@
+using System;
+
+using IBatisNet.DataMapper.TypesHandler;
+
+namespace IBatisNet.DataMapper.Test.Domain
+{
+ /// <summary>
+ /// YesNoBoolTypeHandlerCallback.
+ /// </summary>
+ public class YesNoBoolTypeHandlerCallback : ITypeHandlerCallback
+ {
+ private const string YES = "Oui";
+ private const string NO = "Non";
+
+ #region ITypeHandlerCallback members
+
+ public object GetNullValue(string nullValue)
+ {
+ if (YES.Equals(nullValue))
+ {
+ return true;
+ }
+ else if (NO.Equals(nullValue))
+ {
+ return false;
+ }
+ else
+ {
+ throw new Exception("Unexpected value " + nullValue + " found where "+YES+" or "+NO+" was expected.");
+ }
+ }
+
+ public object GetResult(IResultGetter getter)
+ {
+ string s = getter.Value as string;
+ if (YES.Equals(s))
+ {
+ return true;
+ }
+ else if (NO.Equals(s))
+ {
+ return false;
+ }
+ else
+ {
+ throw new Exception("Unexpected value " + s + " found where "+YES+" or "+NO+" was expected.");
+ }
+ }
+
+ public void SetParameter(IParameterSetter setter, object parameter)
+ {
+ bool b = Convert.ToBoolean(parameter);
+ if (b)
+ {
+ setter.Value = YES;
+ }
+ else
+ {
+ setter.Value = NO;
+ }
+ }
+
+ #endregion
+ }
+}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj Sun May 8 09:20:30 2005
@@ -268,6 +268,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Domain\YesNoBoolTypeHandlerCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Maps\Access\OleDb\Account.xml"
BuildAction = "Content"
/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml Sun May 8 09:20:30 2005
@@ -4,13 +4,15 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- </alias>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
<resultMaps>
<resultMap id="other-result" class="Other" >
<result property="Int" column="Other_Int"/>
<result property="Long" column="Other_Long"/>
- <result property="Bool" column="Other_Bit"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -22,7 +24,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -41,7 +44,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -49,10 +53,40 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
- </statement>
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
</statements>
-
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
+
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml Sun May 8 09:20:30 2005
@@ -4,13 +4,15 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- </alias>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
<resultMaps>
<resultMap id="other-result" class="Other" >
<result property="Int" column="Other_Int"/>
<result property="Long" column="Other_Long"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -22,7 +24,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -41,7 +44,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -49,10 +53,39 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
- </statement>
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
</statements>
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml Sun May 8 09:20:30 2005
@@ -4,13 +4,15 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- </alias>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
<resultMaps>
<resultMap id="other-result" class="Other" >
<result property="Int" column="Other_Int"/>
<result property="Long" column="Other_Long"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -22,7 +24,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -41,7 +44,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -49,11 +53,40 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
</statement>
</statements>
-
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
+
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml Sun May 8 09:20:30 2005
@@ -4,13 +4,15 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
-
+
<resultMaps>
<resultMap id="other-result" class="Other" >
<result property="Int" column="Other_Int"/>
<result property="Long" column="Other_Long"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -22,7 +24,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -41,7 +44,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -49,11 +53,40 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
+ ( #Int#, #Long#, #Bool#, 'Yes')
</statement>
-
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
</statements>
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml Sun May 8 09:20:30 2005
@@ -4,13 +4,15 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
-
+
<resultMaps>
<resultMap id="other-result" class="Other" >
<result property="Int" column="Other_Int"/>
<result property="Long" column="Other_Long"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -22,7 +24,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -41,7 +44,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -49,11 +53,38 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
+ ( #Int#, #Long#, #Bool#, 'Yes')
</statement>
-
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
</statements>
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml Sun May 8 09:20:30 2005
@@ -4,6 +4,7 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
@@ -11,6 +12,7 @@
<result property="Int" column="Other_Int" dbType="Int32"/>
<result property="Long" column="Other_Long" dbType="Int64"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -37,7 +39,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -69,7 +72,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -89,11 +93,40 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
+ ( #Int#, #Long#, #Bool#, 'Yes')
</statement>
+
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
</statements>
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml Sun May 8 09:20:30 2005
@@ -4,6 +4,7 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
@@ -11,6 +12,7 @@
<result property="Int" column="Other_Int" dbType="Int32"/>
<result property="Long" column="Other_Long" dbType="Int64"/>
<result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
</resultMap>
</resultMaps>
@@ -37,7 +39,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
<dynamic prepend="WHERE">
<isNotEqual prepend="AND" property="year" compareValue="0">
@@ -71,7 +74,8 @@
select
Other_Int,
Other_Long,
- Other_Bit
+ Other_Bit,
+ Other_String
from Others
Where Other_Bit = #Bool#
</statement>
@@ -79,11 +83,39 @@
<statement id="InsertBool"
parameterClass="Other">
Insert into Others
- ( Other_Int, Other_Long, Other_Bit )
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
values
- ( #Int#, #Long#, #Bool#)
+ ( #Int#, #Long#, #Bool#, 'Yes')
</statement>
+ <statement id="InsertCustomTypeHnadler"
+ parameterMap="insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
</statements>
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+ </parameterMaps>
</sqlMap>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs Sun May 8 09:20:30 2005
@@ -1,49 +1,44 @@
+
using System;
using System.Collections;
-using System.Configuration;
-
-using NUnit.Framework;
-
-using IBatisNet.DataMapper; //<-- To access the definition of the deleagte RowDelegate
-using IBatisNet.DataMapper.MappedStatements; //<-- To access the definition of the PageinatedList
using IBatisNet.Common;
using IBatisNet.Common.Exceptions;
-
-using IBatisNet.DataMapper.Test;
+using IBatisNet.DataMapper.MappedStatements;
using IBatisNet.DataMapper.Test.Domain;
+using NUnit.Framework;
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
{
/// <summary>
/// Summary description for ParameterMapTest.
/// </summary>
- [TestFixture]
+ [TestFixture]
public class StatementTest : BaseTest
{
-
#region SetUp & TearDown
/// <summary>
/// SetUp
/// </summary>
- [SetUp]
- public void Init()
+ [SetUp]
+ public void Init()
{
InitSqlMap();
- InitScript( sqlMap.DataSource, ScriptDirectory + "account-init.sql" );
- InitScript( sqlMap.DataSource, ScriptDirectory + "order-init.sql" );
- InitScript( sqlMap.DataSource, ScriptDirectory + "line-item-init.sql" );
- InitScript( sqlMap.DataSource, ScriptDirectory + "enumeration-init.sql" );
- InitScript( sqlMap.DataSource, ScriptDirectory + "other-init.sql" );
+ InitScript(sqlMap.DataSource, ScriptDirectory + "account-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "order-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "line-item-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "enumeration-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "other-init.sql");
}
/// <summary>
/// TearDown
/// </summary>
- [TearDown]
+ [TearDown]
public void Dispose()
- { /* ... */ }
+ { /* ... */
+ }
#endregion
@@ -53,8 +48,8 @@
/// Test use a satement with property subtitution
/// (JIRA 22)
/// </summary>
- [Test]
- public void TestSelectWithProperty()
+ [Test]
+ public void TestSelectWithProperty()
{
Account account = sqlMap.QueryForObject("SelectWithProperty", null) as Account;
AssertAccount1(account);
@@ -63,8 +58,8 @@
/// <summary>
/// Test ExecuteQueryForObject Via ColumnName
/// </summary>
- [Test]
- public void TestExecuteQueryForObjectViaColumnName()
+ [Test]
+ public void TestExecuteQueryForObjectViaColumnName()
{
Account account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
AssertAccount1(account);
@@ -73,8 +68,8 @@
/// <summary>
/// Test ExecuteQueryForObject Via ColumnIndex
/// </summary>
- [Test]
- public void TestExecuteQueryForObjectViaColumnIndex()
+ [Test]
+ public void TestExecuteQueryForObjectViaColumnIndex()
{
Account account = sqlMap.QueryForObject("GetAccountViaColumnIndex", 1) as Account;
AssertAccount1(account);
@@ -83,7 +78,7 @@
/// <summary>
/// Test ExecuteQueryForObject Via ResultClass
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectViaResultClass()
{
Account account = sqlMap.QueryForObject("GetAccountViaResultClass", 1) as Account;
@@ -93,7 +88,7 @@
/// <summary>
/// Test ExecuteQueryForObject With simple ResultClass : string
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectWithSimpleResultClass()
{
string email = sqlMap.QueryForObject("GetEmailAddressViaResultClass", 1) as string;
@@ -103,7 +98,7 @@
/// <summary>
/// Test ExecuteQueryForObject With simple ResultMap : string
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectWithSimpleResultMap()
{
string email = sqlMap.QueryForObject("GetEmailAddressViaResultMap", 1) as string;
@@ -116,14 +111,14 @@
[Test]
public void TestPrimitiveReturnValue()
{
- System.DateTime CardExpiry = (System.DateTime) sqlMap.QueryForObject("GetOrderCardExpiryViaResultClass", 1);
- Assert.AreEqual( new DateTime( 2003, 02, 15, 8, 15, 00 ), CardExpiry );
+ DateTime CardExpiry = (DateTime) sqlMap.QueryForObject("GetOrderCardExpiryViaResultClass", 1);
+ Assert.AreEqual(new DateTime(2003, 02, 15, 8, 15, 00), CardExpiry);
}
/// <summary>
/// Test ExecuteQueryForObject with result object : Account
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectWithResultObject()
{
Account account = new Account();
@@ -135,8 +130,8 @@
/// <summary>
/// Test ExecuteQueryForObject as Hashtable
/// </summary>
- [Test]
- public void TestExecuteQueryForObjectAsHashtable()
+ [Test]
+ public void TestExecuteQueryForObjectAsHashtable()
{
Hashtable account = (Hashtable) sqlMap.QueryForObject("GetAccountAsHashtable", 1);
AssertAccount1AsHashtable(account);
@@ -146,9 +141,8 @@
/// Test ExecuteQueryForObject as Hashtable ResultClass
/// </summary>
[Test]
- public void TestExecuteQueryForObjectAsHashtableResultClass()
+ public void TestExecuteQueryForObjectAsHashtableResultClass()
{
-
Hashtable account = (Hashtable) sqlMap.QueryForObject("GetAccountAsHashtableResultClass", 1);
AssertAccount1AsHashtable(account);
}
@@ -161,7 +155,7 @@
{
Hashtable param = new Hashtable();
param.Add("LineItem_ID", 2);
- param.Add("Order_ID", 9);
+ param.Add("Order_ID", 9);
LineItem testItem = sqlMap.QueryForObject("GetSpecificLineItem", param) as LineItem;
@@ -173,7 +167,7 @@
/// Test Query Dynamic Sql Element
/// </summary>
[Test]
- public void TestQueryDynamicSqlElement()
+ public void TestQueryDynamicSqlElement()
{
IList list = sqlMap.QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID");
@@ -189,20 +183,19 @@
/// Test Execute QueryForList With ResultMap With Dynamic Element
/// </summary>
[Test]
- public void TestExecuteQueryForListWithResultMapWithDynamicElement()
+ public void TestExecuteQueryForListWithResultMapWithDynamicElement()
{
-
IList list = sqlMap.QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE");
AssertAccount1((Account) list[0]);
- Assert.AreEqual(3, list.Count );
- Assert.AreEqual(1, ((Account) list[0]).Id );
- Assert.AreEqual(2, ((Account) list[1]).Id );
- Assert.AreEqual(4, ((Account) list[2]).Id );
+ Assert.AreEqual(3, list.Count);
+ Assert.AreEqual(1, ((Account) list[0]).Id);
+ Assert.AreEqual(2, ((Account) list[1]).Id);
+ Assert.AreEqual(4, ((Account) list[2]).Id);
list = sqlMap.QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "=");
- Assert.AreEqual(0, list.Count );
+ Assert.AreEqual(0, list.Count);
}
/// <summary>
@@ -210,15 +203,9 @@
/// </summary>
[Test]
[Ignore("No longer supported.")]
- public void TestSimpleDynamicSubstitution()
+ public void TestSimpleDynamicSubstitution()
{
- string statement = "select" +
- " Account_ID as Id," +
- " Account_FirstName as FirstName," +
- " Account_LastName as LastName," +
- " Account_Email as EmailAddress" +
- " from Accounts" +
- " WHERE Account_ID = #id#";
+ string statement = "select" + " Account_ID as Id," + " Account_FirstName as FirstName," + " Account_LastName as LastName," + " Account_Email as EmailAddress" + " from Accounts" + " WHERE Account_ID = #id#";
Hashtable param = new Hashtable();
param.Add("id", 1);
@@ -227,27 +214,27 @@
IList list = sqlMap.QueryForList("SimpleDynamicSubstitution", param);
AssertAccount1((Account) list[0]);
- Assert.AreEqual(1, list.Count );
+ Assert.AreEqual(1, list.Count);
}
/// <summary>
/// Test Get Account Via Inline Parameters
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectViaInlineParameters()
{
Account account = new Account();
account.Id = 1;
Account testAccount = sqlMap.QueryForObject("GetAccountViaInlineParameters", account) as Account;
-
+
AssertAccount1(testAccount);
}
/// <summary>
/// Test ExecuteQuery For Object With Enum property
/// </summary>
- [Test]
+ [Test]
public void TestExecuteQueryForObjectWithEnum()
{
Enumeration enumClass = sqlMap.QueryForObject("GetEnumeration", 1) as Enumeration;
@@ -262,6 +249,7 @@
Assert.AreEqual(enumClass.Color, Colors.Blue);
Assert.AreEqual(enumClass.Month, Months.September);
}
+
#endregion
#region List Query tests
@@ -270,7 +258,7 @@
/// Test QueryForList with Hashtable ResultMap
/// </summary>
[Test]
- public void TestQueryForListWithHashtableResultMap()
+ public void TestQueryForListWithHashtableResultMap()
{
IList list = sqlMap.QueryForList("GetAllAccountsAsHashMapViaResultMap", null);
@@ -288,7 +276,7 @@
/// Test QueryForList with Hashtable ResultClass
/// </summary>
[Test]
- public void TestQueryForListWithHashtableResultClass()
+ public void TestQueryForListWithHashtableResultClass()
{
IList list = sqlMap.QueryForList("GetAllAccountsAsHashtableViaResultClass", null);
@@ -305,7 +293,7 @@
/// <summary>
/// Test QueryForList With ResultMap, result collection as ArrayList
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListWithResultMap()
{
IList list = sqlMap.QueryForList("GetAllAccountsViaResultMap", null);
@@ -319,8 +307,8 @@
Assert.AreEqual(5, ((Account) list[4]).Id);
}
- [Test]
- public void TestExecuteQueryForPaginatedList()
+ [Test]
+ public void TestExecuteQueryForPaginatedList()
{
// Get List of all 5
PaginatedList list = sqlMap.QueryForPaginatedList("GetAllAccountsViaResultMap", null, 2);
@@ -330,7 +318,7 @@
Assert.IsTrue(list.IsNextPageAvailable);
AssertAccount1((Account) list[0]);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(1, ((Account) list[0]).Id );
+ Assert.AreEqual(1, ((Account) list[0]).Id);
Assert.AreEqual(2, ((Account) list[1]).Id);
// Test illegal previous page (no effect, state should be same)
@@ -339,7 +327,7 @@
Assert.IsTrue(list.IsNextPageAvailable);
AssertAccount1((Account) list[0]);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(1, ((Account) list[0]).Id );
+ Assert.AreEqual(1, ((Account) list[0]).Id);
Assert.AreEqual(2, ((Account) list[1]).Id);
// Test next (page 1)
@@ -347,7 +335,7 @@
Assert.IsTrue(list.IsPreviousPageAvailable);
Assert.IsTrue(list.IsNextPageAvailable);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(3, ((Account) list[0]).Id );
+ Assert.AreEqual(3, ((Account) list[0]).Id);
Assert.AreEqual(4, ((Account) list[1]).Id);
// Test next (page 2 -last)
@@ -355,14 +343,14 @@
Assert.IsTrue(list.IsPreviousPageAvailable);
Assert.IsFalse(list.IsNextPageAvailable);
Assert.AreEqual(1, list.Count);
- Assert.AreEqual(5, ((Account) list[0]).Id );
+ Assert.AreEqual(5, ((Account) list[0]).Id);
// Test previous (page 1)
list.PreviousPage();
Assert.IsTrue(list.IsPreviousPageAvailable);
Assert.IsTrue(list.IsNextPageAvailable);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(3, ((Account) list[0]).Id );
+ Assert.AreEqual(3, ((Account) list[0]).Id);
Assert.AreEqual(4, ((Account) list[1]).Id);
// Test previous (page 0 -first)
@@ -371,7 +359,7 @@
Assert.IsTrue(list.IsNextPageAvailable);
AssertAccount1((Account) list[0]);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(1, ((Account) list[0]).Id );
+ Assert.AreEqual(1, ((Account) list[0]).Id);
Assert.AreEqual(2, ((Account) list[1]).Id);
// Test goto (page 0)
@@ -379,7 +367,7 @@
Assert.IsFalse(list.IsPreviousPageAvailable);
Assert.IsTrue(list.IsNextPageAvailable);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(1, ((Account) list[0]).Id );
+ Assert.AreEqual(1, ((Account) list[0]).Id);
Assert.AreEqual(2, ((Account) list[1]).Id);
// Test goto (page 1)
@@ -387,7 +375,7 @@
Assert.IsTrue(list.IsPreviousPageAvailable);
Assert.IsTrue(list.IsNextPageAvailable);
Assert.AreEqual(2, list.Count);
- Assert.AreEqual(3, ((Account) list[0]).Id );
+ Assert.AreEqual(3, ((Account) list[0]).Id);
Assert.AreEqual(4, ((Account) list[1]).Id);
// Test goto (page 2)
@@ -395,7 +383,7 @@
Assert.IsTrue(list.IsPreviousPageAvailable);
Assert.IsFalse(list.IsNextPageAvailable);
Assert.AreEqual(1, list.Count);
- Assert.AreEqual(5, ((Account) list[0]).Id );
+ Assert.AreEqual(5, ((Account) list[0]).Id);
// Test illegal goto (page 0)
list.GotoPage(3);
@@ -453,11 +441,11 @@
Assert.AreEqual(1, list.Count);
// Test Even - Two Pages
- try
+ try
{
- InitScript( sqlMap.DataSource, ScriptDirectory + "more-account-records.sql" );
- }
- catch (Exception e)
+ InitScript(sqlMap.DataSource, ScriptDirectory + "more-account-records.sql");
+ }
+ catch (Exception e)
{
Console.WriteLine(e.Message);
}
@@ -478,7 +466,7 @@
/// Test QueryForList with ResultObject :
/// AccountCollection strongly typed collection
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListWithResultObject()
{
AccountCollection accounts = new AccountCollection();
@@ -497,10 +485,10 @@
/// <summary>
/// Test QueryForList with ListClass : LineItemCollection
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListWithListClass()
{
- LineItemCollection linesItem= sqlMap.QueryForList("GetLineItemsForOrderWithListClass", 10) as LineItemCollection;
+ LineItemCollection linesItem = sqlMap.QueryForList("GetLineItemsForOrderWithListClass", 10) as LineItemCollection;
Assert.IsNotNull(linesItem);
Assert.AreEqual(2, linesItem.Count);
@@ -511,7 +499,7 @@
/// <summary>
/// Test QueryForList with no result.
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListWithNoResult()
{
IList list = sqlMap.QueryForList("GetNoAccountsViaResultMap", null);
@@ -522,7 +510,7 @@
/// <summary>
/// Test QueryForList with ResultClass : Account.
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListResultClass()
{
IList list = sqlMap.QueryForList("GetAllAccountsViaResultClass", null);
@@ -539,30 +527,30 @@
/// <summary>
/// Test QueryForList with simple resultClass : string
/// </summary>
- [Test]
+ [Test]
public void TestQueryForListWithSimpleResultClass()
{
IList list = sqlMap.QueryForList("GetAllEmailAddressesViaResultClass", null);
- Assert.AreEqual("Joe.Dalton@somewhere.com", (string)list[0]);
- Assert.AreEqual("Averel.Dalton@somewhere.com", (string)list[1]);
+ Assert.AreEqual("Joe.Dalton@somewhere.com", (string) list[0]);
+ Assert.AreEqual("Averel.Dalton@somewhere.com", (string) list[1]);
Assert.IsNull(list[2]);
- Assert.AreEqual("Jack.Dalton@somewhere.com", (string)list[3]);
+ Assert.AreEqual("Jack.Dalton@somewhere.com", (string) list[3]);
Assert.IsNull(list[4]);
}
/// <summary>
/// Test QueryForList with simple ResultMap : string
/// </summary>
- [Test]
- public void TestQueryForListWithSimpleResultMap()
+ [Test]
+ public void TestQueryForListWithSimpleResultMap()
{
IList list = sqlMap.QueryForList("GetAllEmailAddressesViaResultMap", null);
- Assert.AreEqual("Joe.Dalton@somewhere.com", (string)list[0]);
- Assert.AreEqual("Averel.Dalton@somewhere.com", (string)list[1]);
+ Assert.AreEqual("Joe.Dalton@somewhere.com", (string) list[0]);
+ Assert.AreEqual("Averel.Dalton@somewhere.com", (string) list[1]);
Assert.IsNull(list[2]);
- Assert.AreEqual("Jack.Dalton@somewhere.com", (string)list[3]);
+ Assert.AreEqual("Jack.Dalton@somewhere.com", (string) list[3]);
Assert.IsNull(list[4]);
}
@@ -570,7 +558,7 @@
/// Test QueryForListWithSkipAndMax
/// </summary>
[Test]
- public void TestQueryForListWithSkipAndMax()
+ public void TestQueryForListWithSkipAndMax()
{
IList list = sqlMap.QueryForList("GetAllAccountsViaResultMap", null, 2, 2);
@@ -581,7 +569,7 @@
[Test]
- public void TestQueryWithRowDelegate()
+ public void TestQueryWithRowDelegate()
{
SqlMapper.RowDelegate handler = new SqlMapper.RowDelegate(this.RowHandler);
@@ -597,6 +585,7 @@
Assert.AreEqual(5, ((Account) list[4]).Id);
}
+
#endregion
#region Map Tests
@@ -604,19 +593,19 @@
/// <summary>
/// Test ExecuteQueryForMap : Hashtable.
/// </summary>
- [Test]
- public void TestExecuteQueryForMap()
+ [Test]
+ public void TestExecuteQueryForMap()
{
IDictionary map = sqlMap.QueryForMap("GetAllAccountsViaResultClass", null, "FirstName");
- Assert.AreEqual( 5, map.Count);
- AssertAccount1( ((Account) map["Joe"]) );
+ Assert.AreEqual(5, map.Count);
+ AssertAccount1(((Account) map["Joe"]));
- Assert.AreEqual( 1, ((Account) map["Joe"]).Id );
- Assert.AreEqual( 2, ((Account) map["Averel"]).Id );
- Assert.AreEqual( 3, ((Account) map["William"]).Id );
- Assert.AreEqual( 4, ((Account) map["Jack"]).Id );
- Assert.AreEqual( 5, ((Account) map["Gilles"]).Id );
+ Assert.AreEqual(1, ((Account) map["Joe"]).Id);
+ Assert.AreEqual(2, ((Account) map["Averel"]).Id);
+ Assert.AreEqual(3, ((Account) map["William"]).Id);
+ Assert.AreEqual(4, ((Account) map["Jack"]).Id);
+ Assert.AreEqual(5, ((Account) map["Gilles"]).Id);
}
/// <summary>
@@ -626,43 +615,44 @@
/// If the keyProperty is an integer, you must acces the map
/// by map[integer] and not by map["integer"]
/// </remarks>
- [Test]
- public void TestExecuteQueryForMap2()
+ [Test]
+ public void TestExecuteQueryForMap2()
{
IDictionary map = sqlMap.QueryForMap("GetAllOrderWithLineItems", null, "PostalCode");
- Assert.AreEqual( 10, map.Count);
+ Assert.AreEqual(10, map.Count);
Order order = ((Order) map["T4H 9G4"]);
- Assert.AreEqual( 2, order.LineItemsIList.Count );
+ Assert.AreEqual(2, order.LineItemsIList.Count);
}
/// <summary>
/// Test ExecuteQueryForMap with value property :
/// "FirstName" as key, "EmailAddress" as value
/// </summary>
- [Test]
- public void TestExecuteQueryForMapWithValueProperty()
+ [Test]
+ public void TestExecuteQueryForMapWithValueProperty()
{
IDictionary map = sqlMap.QueryForMap("GetAllAccountsViaResultClass", null, "FirstName", "EmailAddress");
- Assert.AreEqual( 5, map.Count);
+ Assert.AreEqual(5, map.Count);
- Assert.AreEqual( "Joe.Dalton@somewhere.com", map["Joe"] );
- Assert.AreEqual( "Averel.Dalton@somewhere.com", map["Averel"] );
- Assert.IsNull( map["William"] );
- Assert.AreEqual( "Jack.Dalton@somewhere.com", map["Jack"] );
- Assert.IsNull( map["Gilles"] );
+ Assert.AreEqual("Joe.Dalton@somewhere.com", map["Joe"]);
+ Assert.AreEqual("Averel.Dalton@somewhere.com", map["Averel"]);
+ Assert.IsNull(map["William"]);
+ Assert.AreEqual("Jack.Dalton@somewhere.com", map["Jack"]);
+ Assert.IsNull(map["Gilles"]);
}
#endregion
#region Extends statement
+
/// <summary>
/// Test base Extends statement
/// </summary>
[Test]
- public void TestExtendsGetAllAccounts()
+ public void TestExtendsGetAllAccounts()
{
IList list = sqlMap.QueryForList("GetAllAccounts", null);
@@ -679,7 +669,7 @@
/// Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts
/// </summary>
[Test]
- public void TestExtendsGetAllAccountsOrderByName()
+ public void TestExtendsGetAllAccountsOrderByName()
{
IList list = sqlMap.QueryForList("GetAllAccountsOrderByName", null);
@@ -697,7 +687,7 @@
/// Test Extends statement GetOneAccount extends GetAllAccounts
/// </summary>
[Test]
- public void TestExtendsGetOneAccount()
+ public void TestExtendsGetOneAccount()
{
Account account = sqlMap.QueryForObject("GetOneAccount", 1) as Account;
AssertAccount1(account);
@@ -707,11 +697,11 @@
/// Test Extends statement GetSomeAccount extends GetAllAccounts
/// </summary>
[Test]
- public void TestExtendsGetSomeAccount()
+ public void TestExtendsGetSomeAccount()
{
Hashtable param = new Hashtable();
param.Add("lowID", 2);
- param.Add("hightID", 4);
+ param.Add("hightID", 4);
IList list = sqlMap.QueryForList("GetSomeAccount", param);
@@ -721,6 +711,7 @@
Assert.AreEqual(3, ((Account) list[1]).Id);
Assert.AreEqual(4, ((Account) list[2]).Id);
}
+
#endregion
#region Update tests
@@ -728,8 +719,8 @@
/// <summary>
/// Test Insert with post GeneratedKey
/// </summary>
- [Test]
- public void TestInsertPostKey()
+ [Test]
+ public void TestInsertPostKey()
{
LineItem item = new LineItem();
@@ -738,7 +729,7 @@
item.Order = new Order();
item.Order.Id = 9;
item.Price = 44.00m;
- item.Quantity= 1;
+ item.Quantity = 1;
object key = sqlMap.Insert("InsertLineItemPostKey", item);
@@ -776,9 +767,9 @@
Hashtable param = new Hashtable();
param.Add("Order_ID", 9);
param.Add("LineItem_ID", 99);
-
+
LineItem testItem = (LineItem) sqlMap.QueryForObject("GetSpecificLineItem", param);
-
+
Assert.IsNotNull(testItem);
Assert.AreEqual(99, testItem.Id);
}
@@ -787,7 +778,7 @@
/// Test Test Insert No Key
/// </summary>
[Test]
- public void TestInsertNoKey()
+ public void TestInsertNoKey()
{
LineItem item = new LineItem();
@@ -806,18 +797,18 @@
Hashtable param = new Hashtable();
param.Add("Order_ID", 9);
param.Add("LineItem_ID", 100);
-
+
LineItem testItem = (LineItem) sqlMap.QueryForObject("GetSpecificLineItem", param);
-
+
Assert.IsNotNull(testItem);
Assert.AreEqual(100, testItem.Id);
}
-
+
/// <summary>
/// Test Insert account via public fields
/// </summary>
[Ignore("No more supported")]
- public void TestInsertAccountViaPublicFields()
+ public void TestInsertAccountViaPublicFields()
{
AccountBis account = new AccountBis();
@@ -837,8 +828,8 @@
/// <summary>
/// Test Insert account via inline parameters
/// </summary>
- [Test]
- public void TestInsertAccountViaInlineParameters()
+ [Test]
+ public void TestInsertAccountViaInlineParameters()
{
Account account = new Account();
@@ -858,7 +849,7 @@
/// <summary>
/// Test Insert account via parameterMap
/// </summary>
- [Test]
+ [Test]
public void TestInsertAccountViaParameterMap()
{
Account account = NewAccount6();
@@ -873,7 +864,7 @@
/// <summary>
/// Test Insert account via parameterMap
/// </summary>
- [Test]
+ [Test]
public void TestInsertEnumViaParameterMap()
{
Enumeration enumClass = new Enumeration();
@@ -900,12 +891,12 @@
{
Account account = (Account) sqlMap.QueryForObject("GetAccountViaColumnName", 1);
- account.EmailAddress = "new@somewhere.com" ;
+ account.EmailAddress = "new@somewhere.com";
sqlMap.Update("UpdateAccountViaParameterMap", account);
account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
- Assert.AreEqual( "new@somewhere.com", account.EmailAddress );
+ Assert.AreEqual("new@somewhere.com", account.EmailAddress);
}
/// <summary>
@@ -916,23 +907,23 @@
{
Account account = (Account) sqlMap.QueryForObject("GetAccountViaColumnName", 1);
- account.EmailAddress = "new@somewhere.com" ;
+ account.EmailAddress = "new@somewhere.com";
sqlMap.Update("UpdateAccountViaParameterMap2", account);
account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
- Assert.AreEqual( "new@somewhere.com", account.EmailAddress );
+ Assert.AreEqual("new@somewhere.com", account.EmailAddress);
}
/// <summary>
/// Test Update with inline parameters
/// </summary>
[Test]
- public void TestUpdateWithInlineParameters()
+ public void TestUpdateWithInlineParameters()
{
Account account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
- account.EmailAddress = "new@somewhere.com" ;
+ account.EmailAddress = "new@somewhere.com";
sqlMap.Update("UpdateAccountViaInlineParameters", account);
account = (Account) sqlMap.QueryForObject("GetAccountViaColumnName", 1);
@@ -944,7 +935,7 @@
/// Test Execute Update With Parameter Class
/// </summary>
[Test]
- public void TestExecuteUpdateWithParameterClass()
+ public void TestExecuteUpdateWithParameterClass()
{
Account account = NewAccount6();
@@ -952,13 +943,13 @@
bool checkForInvalidTypeFailedAppropriately = false;
- try
+ try
{
sqlMap.Update("DeleteAccount", new object());
- }
- catch (IBatisNetException e)
+ }
+ catch (IBatisNetException e)
{
- Console.WriteLine("TestExecuteUpdateWithParameterClass :"+e.Message);
+ Console.WriteLine("TestExecuteUpdateWithParameterClass :" + e.Message);
checkForInvalidTypeFailedAppropriately = true;
}
@@ -974,7 +965,7 @@
/// Test Execute Delete
/// </summary>
[Test]
- public void TestExecuteDelete()
+ public void TestExecuteDelete()
{
Account account = NewAccount6();
@@ -983,10 +974,10 @@
account = null;
account = sqlMap.QueryForObject("GetAccountViaColumnName", 6) as Account;
- Assert.IsTrue( account.Id == 6 );
+ Assert.IsTrue(account.Id == 6);
int rowNumber = sqlMap.Delete("DeleteAccount", account);
- Assert.IsTrue( rowNumber==1 );
+ Assert.IsTrue(rowNumber == 1);
account = sqlMap.QueryForObject("GetAccountViaColumnName", 6) as Account;
@@ -997,12 +988,13 @@
/// Test Execute Delete
/// </summary>
[Test]
- public void TestDeleteWithComments()
+ public void TestDeleteWithComments()
{
int rowNumber = sqlMap.Delete("DeleteWithComments", null);
- Assert.IsTrue( rowNumber==4 );
+ Assert.IsTrue(rowNumber == 4);
}
+
#endregion
#region Row delegate
@@ -1012,7 +1004,7 @@
public void RowHandler(object obj, IList list)
{
_index++;
- Assert.AreEqual( _index, ((Account) obj).Id);
+ Assert.AreEqual(_index, ((Account) obj).Id);
list.Add(obj);
}
@@ -1023,38 +1015,38 @@
/// <summary>
/// Test Test Using syntax on sqlMap.OpenConnection
/// </summary>
- [Test]
- public void TestUsingConnection()
+ [Test]
+ public void TestUsingConnection()
{
- using ( IDalSession session = sqlMap.OpenConnection() )
+ using (IDalSession session = sqlMap.OpenConnection())
{
Account account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
AssertAccount1(account);
- } // compiler will call Dispose on SqlMapSession
+ } // compiler will call Dispose on SqlMapSession
}
/// <summary>
/// Test Using syntax on sqlMap.BeginTransaction
/// </summary>
- [Test]
- public void TestUsingTransaction()
+ [Test]
+ public void TestUsingTransaction()
{
- using ( IDalSession session = sqlMap.BeginTransaction() )
+ using (IDalSession session = sqlMap.BeginTransaction())
{
Account account = (Account) sqlMap.QueryForObject("GetAccountViaColumnName", 1);
- account.EmailAddress = "new@somewhere.com" ;
+ account.EmailAddress = "new@somewhere.com";
sqlMap.Update("UpdateAccountViaParameterMap", account);
account = sqlMap.QueryForObject("GetAccountViaColumnName", 1) as Account;
- Assert.AreEqual( "new@somewhere.com", account.EmailAddress );
+ Assert.AreEqual("new@somewhere.com", account.EmailAddress);
session.Complete(); // Commit
- } // compiler will call Dispose on SqlMapSession
+ } // compiler will call Dispose on SqlMapSession
}
- #endregion
+ #endregion
#region JIRA Tests
@@ -1062,7 +1054,7 @@
/// Test Bit column
/// </summary>
[Test]
- public void TestJIRA42()
+ public void TestJIRA42()
{
Other other = new Other();
@@ -1077,7 +1069,7 @@
/// Test for access a result map in a different namespace
/// </summary>
[Test]
- public void TestJIRA45()
+ public void TestJIRA45()
{
Account account = sqlMap.QueryForObject("GetAccountJIRA45", 1) as Account;
AssertAccount1(account);
@@ -1085,7 +1077,33 @@
#endregion
+ #region CustomTypeHandler tests
+
+ /// <summary>
+ /// Test CustomTypeHandler Oui/Non
+ /// </summary>
+ [Test]
+ public void TestCustomTypeHandler()
+ {
+ Other other = new Other();
+ other.Int = 99;
+ other.Long = 1966;
+ other.Bool = true;
+ other.Bool2 = false;
+
+ sqlMap.Insert("InsertCustomTypeHnadler", other);
+
+ Other anOther = sqlMap.QueryForObject("SelectByInt", 99) as Other;
+
+ Assert.IsNotNull( anOther );
+ Assert.AreEqual(99, anOther.Int);
+ Assert.AreEqual(1966, anOther.Long);
+ Assert.AreEqual(true, anOther.Bool);
+ Assert.AreEqual(false, anOther.Bool2);
+ }
+ #endregion
+
+
-
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/other-init.sql
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/other-init.sql?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/other-init.sql (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/other-init.sql Sun May 8 09:20:30 2005
@@ -10,10 +10,11 @@
CREATE TABLE [dbo].[Others] (
[Other_Int] [int] NULL ,
[Other_Long] [BigInt] NULL,
- [Other_Bit] [Bit] NOT NULL DEFAULT (0)
+ [Other_Bit] [Bit] NOT NULL DEFAULT (0),
+ [Other_String] [varchar] (32) NOT NULL
) ON [PRIMARY]
-- Creating Test Data
-INSERT INTO [dbo].[Others] VALUES(1, 8888888, 0);
-INSERT INTO [dbo].[Others] VALUES(2, 9999999999, 1);
\ No newline at end of file
+INSERT INTO [dbo].[Others] VALUES(1, 8888888, 0, 'Oui');
+INSERT INTO [dbo].[Others] VALUES(2, 9999999999, 1, 'Non');
\ No newline at end of file
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql/other-init.sql
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql/other-init.sql?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql/other-init.sql (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql/other-init.sql Sun May 8 09:20:30 2005
@@ -5,10 +5,11 @@
create table Others
(
- Other_Int int,
+ Other_Int int,
Other_Long bigint,
- Other_Bit bit not null default 0
+ Other_Bit bit not null default 0,
+ Other_String varchar(32) not null
) TYPE=INNODB;
-INSERT INTO Others VALUES(1, 8888888, 0);
-INSERT INTO Others VALUES(2, 9999999999, 1);
\ No newline at end of file
+INSERT INTO Others VALUES(1, 8888888, 0, 'Oui');
+INSERT INTO Others VALUES(2, 9999999999, 1, 'Non');
\ No newline at end of file
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle/other-init.sql
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle/other-init.sql?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle/other-init.sql (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle/other-init.sql Sun May 8 09:20:30 2005
@@ -3,11 +3,12 @@
CREATE TABLE OTHERS (
OTHER_INT INT NULL ,
OTHER_LONG NUMBER NULL ,
- OTHER_BIT SMALLINT DEFAULT 0 NOT NULL
+ OTHER_BIT SMALLINT DEFAULT 0 NOT NULL,
+ OTHER_STRING VARCHAR2(32) NOT NULL
)
NOLOGGING
NOCACHE
NOPARALLEL;
-INSERT INTO OTHERS VALUES(1, 8888888, 0);
-INSERT INTO OTHERS VALUES(2, 9999999999, 1);
\ No newline at end of file
+INSERT INTO OTHERS VALUES(1, 8888888, 0, 'Oui');
+INSERT INTO OTHERS VALUES(2, 9999999999, 1, 'Non');
\ No newline at end of file
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config Sun May 8 09:20:30 2005
@@ -47,7 +47,7 @@
<!-- OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL -->
<!-- Set root logger level to ERROR and its appenders -->
<root>
- <level value="DEBUG" />
+ <level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
@@ -57,7 +57,7 @@
<level value="DEBUG" />
</logger>
<logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory">
- <level value="OFF" />
+ <level value="DEBUG" />
</logger>
<logger name="IBatisNet.DataMapper.Commands.IPreparedCommand">
<level value="DEBUG" />
@@ -77,7 +77,7 @@
<logger name="IBatisNet.DataAccess.Configuration.DaoProxy">
<level value="DEBUG" />
</logger>
- <logger name="System.Data.IDbConnection">
+ <logger name="IBatisNet.DataMapper.Commands.DefaultPreparedCommand">
<level value="DEBUG" />
</logger>
</log4net>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs Sun May 8 09:20:30 2005
@@ -106,6 +106,8 @@
{
IDataParameter sqlParameter = (IDataParameter)parameters[i];
string propertyName = (string)properties[i];
+ IDataParameter parameterCopy = command.CreateParameter();
+ ParameterProperty property = request.ParameterMap.GetProperty(i);
#region Logging
if (_logger.IsDebugEnabled)
@@ -119,9 +121,11 @@
if (command.CommandType == CommandType.Text)
{
+
+ #region text command
+
if ( propertyName != "value" ) // Inline Parameters && Parameters via ParameterMap
{
- ParameterProperty property = request.ParameterMap.GetProperty(i);
parameterValue = request.ParameterMap.GetValueOfProperty(parameterObject,
property.PropertyName);
@@ -146,9 +150,12 @@
}
#endregion
}
+ #endregion
}
else // CommandType.StoredProcedure
{
+ #region store procedure command
+
// A store procedure must always use a ParameterMap
// to indicate the mapping order of the properties to the columns
if (request.ParameterMap == null) // Inline Parameters
@@ -157,17 +164,17 @@
}
else // Parameters via ParameterMap
{
- ParameterProperty property = request.ParameterMap.GetProperty(i);
+// ParameterProperty property = request.ParameterMap.GetProperty(i);
if (property.DirectionAttribut.Length == 0)
{
property.Direction = sqlParameter.Direction;
}
- // IDbDataParameter dataParameter = (IDbDataParameter)parameters[i];
- // property.Precision = dataParameter.Precision;
- // property.Scale = dataParameter.Scale;
- // property.Size = dataParameter.Size;
+ // DbDataParameter dataParameter = (IDbDataParameter)parameters[i];
+ // property.Precision = dataParameter.Precision;
+ // property.Scale = dataParameter.Scale;
+ // property.Size = dataParameter.Size;
sqlParameter.Direction = property.Direction;
parameterValue = request.ParameterMap.GetValueOfProperty( parameterObject, property.PropertyName );
@@ -180,13 +187,14 @@
}
#endregion
}
+ #endregion
}
- IDataParameter parameterCopy = command.CreateParameter();
// Fix JIRA 20
- sqlParameter.Value = parameterValue;
- parameterCopy.Value = parameterValue;
+ //parameterCopy.Value = parameterValue;
+ property.TypeHandler.SetParameter(property, parameterCopy, parameterValue);
+
#region Logging
if (_logger.IsDebugEnabled)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Sun May 8 09:20:30 2005
@@ -117,8 +117,20 @@
#region Fields
private ConfigurationScope _configScope = null;
- private InlineParameterMapParser _paramParser = new InlineParameterMapParser();
+ private InlineParameterMapParser _paramParser = null;
+ #endregion
+
+ #region Constructor
+
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public DomSqlMapBuilder()
+ {
+ _configScope = new ConfigurationScope();
+ _paramParser = new InlineParameterMapParser(_configScope.ErrorContext);
+ }
#endregion
#region Methods
@@ -135,8 +147,6 @@
DataSource dataSource,
bool useConfigFileWatcher, bool isCallFromDao)
{
- _configScope = new ConfigurationScope();
-
_configScope.SqlMapConfigDocument = document;
_configScope.DataSource = dataSource;
_configScope.IsCallFromDao = isCallFromDao;
@@ -1119,8 +1129,9 @@
{
parameterMap = (ParameterMap) serializer.Deserialize(new XmlNodeReader(parameterMapNode));
- _configScope.ErrorContext.MoreInfo = "initialize ParameterMap";
- parameterMap.Initialize(parameterMapNode);
+ _configScope.ErrorContext.MoreInfo = "Initialize ParameterMap";
+ _configScope.NodeContext = parameterMapNode;
+ parameterMap.Initialize( _configScope );
parameterMap.Id = ApplyNamespace( parameterMap.Id );
string attributeExtendMap = parameterMap.ExtendMap;
@@ -1187,7 +1198,7 @@
resultMap.SqlMapNameSpace = _configScope.SqlMapNamespace;
_configScope.ErrorContext.MoreInfo = "initialize ResultMap";
- resultMap.Initialize( _configScope.SqlMapper, resultMapNode);
+ resultMap.Initialize( _configScope );
resultMap.Id = ApplyNamespace( resultMap.Id );
string attributeExtendMap = resultMap.ExtendMap;
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/InlineParameterMapParser.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/InlineParameterMapParser.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/InlineParameterMapParser.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/InlineParameterMapParser.cs Sun May 8 09:20:30 2005
@@ -30,6 +30,7 @@
using System.Text;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic;
+using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypesHandler;
using IBatisNet.DataMapper.Exceptions;
@@ -53,6 +54,8 @@
private const string PARAMETER_TOKEN = "#";
private const string PARAM_DELIM = ":";
+ private ErrorContext _errorContext= null;
+
#endregion
#region Constructors
@@ -60,8 +63,11 @@
/// <summary>
/// Constructor
/// </summary>
- public InlineParameterMapParser()
- {}
+ /// <param name="errorContext"></param>
+ public InlineParameterMapParser(ErrorContext errorContext)
+ {
+ _errorContext = errorContext;
+ }
#endregion
/// <summary>
@@ -139,6 +145,7 @@
return sqlText;
}
+
private ParameterProperty ParseMapping(string token, Type parameterClass)
{
ParameterProperty mapping = new ParameterProperty();
@@ -172,7 +179,7 @@
//
}
mapping.TypeHandler = handler;
- mapping.Initialize();
+ mapping.Initialize(_errorContext);
}
else if (n1 >= 5)
{
@@ -204,7 +211,7 @@
//
}
mapping.TypeHandler = handler;
- mapping.Initialize();
+ mapping.Initialize(_errorContext);
}
else
{
@@ -226,10 +233,11 @@
//TypeHandlerFactory.GetTypeHandler(parameterClass);
}
mapping.TypeHandler = handler;
- mapping.Initialize();
+ mapping.Initialize(_errorContext);
}
return mapping;
}
+
/// <summary>
/// Resolve TypeHandler
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterMap.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterMap.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterMap.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterMap.cs Sun May 8 09:20:30 2005
@@ -24,7 +24,7 @@
********************************************************************************/
#endregion
-#region Imports
+#region Using
using System;
using System.Collections;
@@ -34,6 +34,7 @@
using System.Xml;
using System.Xml.Serialization;
using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.DataMapper.Scope;
#endregion
@@ -255,7 +256,7 @@
if ( object.Equals(propertyValue, nullValue) )
{
- propertyValue = DBNull.Value; ;
+ propertyValue = null; ;
}
else
{
@@ -300,14 +301,14 @@
if ( object.Equals(propertyValue, nullValue) )
{
- propertyValue = DBNull.Value; ;
+ propertyValue = null; ;
}
}
else
{
if (propertyValue == null)
{
- propertyValue = DBNull.Value; ;
+ propertyValue = null; ;
}
}
}
@@ -321,27 +322,27 @@
/// <summary>
/// Initialize the parameter properties child.
/// </summary>
- /// <param name="node"></param>
- public void Initialize(XmlNode node)
+ /// <param name="configScope"></param>
+ public void Initialize(ConfigurationScope configScope)
{
- GetProperties( node);
+ GetProperties( configScope );
}
/// <summary>
/// Get the parameter properties child for the xmlNode parameter.
/// </summary>
- /// <param name="node">An xmlNode.</param>
- private void GetProperties(XmlNode node)
+ /// <param name="configScope"></param>
+ private void GetProperties(ConfigurationScope configScope)
{
XmlSerializer serializer = null;
ParameterProperty property = null;
serializer = new XmlSerializer(typeof(ParameterProperty));
- foreach ( XmlNode parameterNode in node.SelectNodes("parameter") )
+ foreach ( XmlNode parameterNode in configScope.NodeContext.SelectNodes("parameter") )
{
property = (ParameterProperty) serializer.Deserialize(new XmlNodeReader(parameterNode));
- property.Initialize();
+ property.Initialize( configScope );
AddParameterProperty(property);
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterProperty.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterProperty.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping/ParameterProperty.cs Sun May 8 09:20:30 2005
@@ -24,14 +24,17 @@
********************************************************************************/
#endregion
-#region Imports
+#region Using
+
using System;
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.DataMapper.Scope;
using IBatisNet.DataMapper.TypesHandler;
+
#endregion
namespace IBatisNet.DataMapper.Configuration.ParameterMapping
@@ -67,11 +70,25 @@
private ITypeHandler _typeHandler = null;
[NonSerialized]
private string _clrType = string.Empty;
+ [NonSerialized]
+ private string _callBackName= string.Empty;
#endregion
#region Properties
+
/// <summary>
- /// Specify the CLR type of the result.
+ /// Specify the custom type handlers to used.
+ /// </summary>
+ /// <remarks>Will be an alias to a class wchic implement ITypeHandlerCallback</remarks>
+ [XmlAttribute("typeHandler")]
+ public string CallBackName
+ {
+ get { return _callBackName; }
+ set { _callBackName = value; }
+ }
+
+ /// <summary>
+ /// Specify the CLR type of the parameter.
/// </summary>
/// <remarks>
/// The type attribute is used to explicitly specify the property type to be read.
@@ -88,7 +105,7 @@
/// <summary>
/// The typeHandler used to work with the parameter.
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public ITypeHandler TypeHandler
{
get { return _typeHandler; }
@@ -165,7 +182,7 @@
/// Indicate the direction of the parameter.
/// </summary>
/// <example> Input, Output, InputOutput</example>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public ParameterDirection Direction
{
get { return _direction; }
@@ -196,7 +213,7 @@
/// <summary>
/// Tell if a nullValue is defined.
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public bool HasNullValue
{
get { return (_nullValue.Length>0); }
@@ -228,18 +245,88 @@
/// <summary>
///
/// </summary>
- public void Initialize()
+ /// <param name="configScope"></param>
+ public void Initialize(ConfigurationScope configScope)
{
if(_directionAttribute.Length >0)
{
_direction = (ParameterDirection)Enum.Parse( typeof(ParameterDirection), _directionAttribute, true );
}
- // If we specify a type, it can be set
- if (this.CLRType != string.Empty)
+
+ configScope.ErrorContext.MoreInfo = "Check the parameter mapping typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
+ if (this.CallBackName.Length >0)
+ {
+ try
+ {
+ Type type = configScope.SqlMapper.GetType(this.CallBackName);
+ ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback) Activator.CreateInstance( type );
+ _typeHandler = new CustomTypeHandler(typeHandlerCallback);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Error occurred during custom type handler configuration. Cause: " + e.Message, e);
+ }
+ }
+ else
{
- _typeHandler = TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
+ if (this.CLRType.Length == 0 ) // Unknown
+ {
+ _typeHandler = TypeHandlerFactory.GetUnkownTypeHandler();
+ }
+ else // If we specify a CLR type, use it
+ {
+ Type type = Resources.TypeForName(this.CLRType);
+
+ if (TypeHandlerFactory.IsSimpleType(type))
+ {
+ // Primitive
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ }
+ else
+ {
+ // .NET object
+ type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ }
+ }
}
}
+
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="errorContext"></param>
+ public void Initialize(ErrorContext errorContext)
+ {
+ if(_directionAttribute.Length >0)
+ {
+ _direction = (ParameterDirection)Enum.Parse( typeof(ParameterDirection), _directionAttribute, true );
+ }
+
+ errorContext.MoreInfo = "Intialize a parameter property '" + this.PropertyName + "' .";
+ if (this.CLRType.Length == 0 ) // Unknown
+ {
+ _typeHandler = TypeHandlerFactory.GetUnkownTypeHandler();
+ }
+ else // If we specify a CLR type, use it
+ {
+ Type type = Resources.TypeForName(this.CLRType);
+
+ if (TypeHandlerFactory.IsSimpleType(type))
+ {
+ // Primitive
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ }
+ else
+ {
+ // .NET object
+ type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ }
+ }
+ }
+
/// <summary>
///
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Sun May 8 09:20:30 2005
@@ -25,18 +25,16 @@
#endregion
#region Imports
+
using System;
using System.Collections;
-using System.Collections.Specialized;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
-
using IBatisNet.Common.Exceptions;
-using IBatisNet.Common.Utilities.TypesResolver;
using IBatisNet.Common.Utilities.Objects;
-using IBatisNet.DataMapper.Configuration.Alias;
-using IBatisNet.DataMapper.TypesHandler;
+using IBatisNet.Common.Utilities.TypesResolver;
+using IBatisNet.DataMapper.Scope;
#endregion
@@ -72,7 +70,7 @@
/// <summary>
/// The sqlMap namespace
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public string SqlMapNameSpace
{
get
@@ -88,7 +86,7 @@
/// <summary>
/// The discriminator used to choose the good SubMap
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public Discriminator Discriminator
{
get
@@ -104,7 +102,7 @@
/// <summary>
/// The collection of result properties.
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public Hashtable ColumnsToPropertiesMap
{
get { return _columnsToPropertiesMap; }
@@ -140,7 +138,7 @@
/// <summary>
/// The output type class of the resultMap.
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public Type Class
{
get { return _class; }
@@ -181,16 +179,16 @@
/// <summary>
/// Initialize the resultMap from an xmlNode..
/// </summary>
- /// <param name="sqlMap">The sqlMap.</param>
- /// <param name="node">An XmlNode.</param>
- public void Initialize( SqlMapper sqlMap, XmlNode node)
+ /// <param name="configScope"></param>
+ public void Initialize( ConfigurationScope configScope )
+ //SqlMapper sqlMap, XmlNode node)
{
try
{
- _class = sqlMap.GetType(_className);
+ _class = configScope.SqlMapper.GetType(_className);
// Load the child node
- GetChildNode(node);
+ GetChildNode(configScope);
}
catch(Exception e)
{
@@ -204,8 +202,8 @@
/// <summary>
/// Get the result properties and the subMap properties.
/// </summary>
- /// <param name="node">An xmlNode.</param>
- private void GetChildNode(XmlNode node)
+ /// <param name="configScope"></param>
+ private void GetChildNode(ConfigurationScope configScope)
{
XmlSerializer serializer = null;
ResultProperty property = null;
@@ -214,7 +212,7 @@
#region Load the Result Properties
serializer = new XmlSerializer(typeof(ResultProperty));
- foreach ( XmlNode resultNode in node.SelectNodes("result") )
+ foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes("result") )
{
property = (ResultProperty) serializer.Deserialize(new XmlNodeReader(resultNode));
@@ -224,7 +222,7 @@
{
propertyInfo = ReflectionInfo.GetInstance(_class).GetSetter( property.PropertyName );
}
- property.Initialize( propertyInfo );
+ property.Initialize( configScope, propertyInfo );
this.AddResultPropery( property );
}
@@ -233,7 +231,7 @@
#region Load the Discriminator Property
serializer = new XmlSerializer(typeof(Discriminator));
- XmlNode discriminatorNode = node.SelectSingleNode("discriminator");
+ XmlNode discriminatorNode = configScope.NodeContext.SelectSingleNode("discriminator");
if (discriminatorNode != null)
{
this.Discriminator = (Discriminator) serializer.Deserialize(new XmlNodeReader(discriminatorNode));
@@ -243,7 +241,7 @@
#region Load the SubMap Properties
serializer = new XmlSerializer(typeof(SubMap));
- foreach ( XmlNode resultNode in node.SelectNodes("subMap") )
+ foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes("subMap") )
{
subMap = (SubMap) serializer.Deserialize(new XmlNodeReader(resultNode));
subMap.ResultMapName = this.SqlMapNameSpace + DomSqlMapBuilder.DOT + subMap.ResultMapName;
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs Sun May 8 09:20:30 2005
@@ -28,7 +28,8 @@
using System;
using System.Reflection;
using System.Xml.Serialization;
-
+using IBatisNet.Common.Exceptions;
+using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypesHandler;
using IBatisNet.Common.Utilities;
#endregion
@@ -72,9 +73,23 @@
private bool _isLazyLoad = false;
[NonSerialized]
private ITypeHandler _typeHandler = null;
+ [NonSerialized]
+ private string _callBackName= string.Empty;
#endregion
#region Properties
+
+ /// <summary>
+ /// Specify the custom type handlers to used.
+ /// </summary>
+ /// <remarks>Will be an alias to a class wchic implement ITypeHandlerCallback</remarks>
+ [XmlAttribute("typeHandler")]
+ public string CallBackName
+ {
+ get { return _callBackName; }
+ set { _callBackName = value; }
+ }
+
/// <summary>
/// Tell us if we must lazy load this property..
/// </summary>
@@ -237,6 +252,42 @@
/// Initialize the PropertyInfo of the result property.
/// </summary>
/// <param name="propertyInfo">A PropertyInfoot.</param>
+ /// <param name="configScope"></param>
+ public void Initialize( ConfigurationScope configScope, PropertyInfo propertyInfo )
+ {
+ _propertyInfo = propertyInfo;
+
+ if ( propertyInfo != null)
+ {
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+ }
+ // If we specify a type, it can overrride
+ if (this.CLRType.Length>0)
+ {
+ _typeHandler = TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
+ }
+ // If we specify a typeHandler, it can overrride
+ if (this.CallBackName.Length >0)
+ {
+ configScope.ErrorContext.MoreInfo = "Check the parameter mapping typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
+ try
+ {
+ Type type = configScope.SqlMapper.GetType(this.CallBackName);
+ ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback) Activator.CreateInstance( type );
+ _typeHandler = new CustomTypeHandler(typeHandlerCallback);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Error occurred during custom type handler configuration. Cause: " + e.Message, e);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Initialize the PropertyInfo of the result property
+ /// for AutoMapper
+ /// </summary>
+ /// <param name="propertyInfo">A PropertyInfoot.</param>
public void Initialize( PropertyInfo propertyInfo )
{
_propertyInfo = propertyInfo;
@@ -246,12 +297,12 @@
_typeHandler = TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
}
// If we specify a type, it can overrride
- if (this.CLRType != string.Empty)
+ if (this.CLRType.Length>0)
{
_typeHandler = TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
}
}
#endregion
-
}
+
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs Sun May 8 09:20:30 2005
@@ -54,7 +54,7 @@
private IList _children = new ArrayList();
private IStatement _statement = null ;
- InlineParameterMapParser _paramParser = new InlineParameterMapParser();
+ InlineParameterMapParser _paramParser = null;
#endregion
@@ -95,6 +95,7 @@
public RequestScope GetRequestScope(object parameterObject, IDalSession session)
{
RequestScope request = new RequestScope();
+ _paramParser = new InlineParameterMapParser(request.ErrorContext);
request.ResultMap = _statement.ResultMap;
string sqlStatement = Process(request, parameterObject);