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/15 18:04:06 UTC
svn commit: r170230 - in
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper: ./ Commands/
Configuration/ParameterMapping/ Configuration/ResultMapping/
MappedStatements/ Scope/ Test/ Test/Domain/ Test/Maps/MSSQL/Odbc/
Test/Maps/MSSQL/OleDb/ Test/Maps/MSSQL/SqlClient/ Test/NUnit/SqlMapTests/
Test/Scripts/MSSQL/ Test/bin/Debug/ TypeHandlers/
Author: gbayon
Date: Sun May 15 09:04:04 2005
New Revision: 170230
URL: http://svn.apache.org/viewcvs?rev=170230&view=rev
Log:
- Updated Nunit test for custom type handler
- refactor init of type thandler on result & parameter property
(nunit tests on MySql & Oracle are out date)
Added:
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/HundredsTypeHandlerCallback.cs
Modified:
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/OneZeroBoolTypeHandlerCallback.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Account.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-procedure.sql
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.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/MappedStatements/MappedStatement.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs
Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/HundredsTypeHandlerCallback.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/HundredsTypeHandlerCallback.cs?rev=170230&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/HundredsTypeHandlerCallback.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/HundredsTypeHandlerCallback.cs Sun May 15 09:04:04 2005
@@ -0,0 +1,63 @@
+using System;
+using IBatisNet.DataMapper.Exceptions;
+using IBatisNet.DataMapper.TypeHandlers;
+
+namespace IBatisNet.DataMapper.Test.Domain
+{
+ /// <summary>
+ /// Description résumée de HundredsTypeHandlerCallback.
+ /// </summary>
+ public class HundredsTypeHandlerCallback : ITypeHandlerCallback
+ {
+
+ #region ITypeHandlerCallback
+
+ public object GetNullValue(string nullValue)
+ {
+ if ("100".Equals(nullValue))
+ {
+ return true;
+ }
+ else if ("200".Equals(nullValue))
+ {
+ return false;
+ }
+ else
+ {
+ throw new DataMapperException("Unexpected value " + nullValue + " found where 100 or 200 was expected.");
+ }
+ }
+
+ public object GetResult(IResultGetter getter)
+ {
+ int i = (int) getter.Value;
+ if (i == 100)
+ {
+ return true;
+ }
+ else if (i == 200)
+ {
+ return false;
+ }
+ else
+ {
+ throw new DataMapperException("Unexpected value " + i + " found where 100 or 200 was expected.");
+ }
+ }
+
+ public void SetParameter(IParameterSetter setter, object parameter)
+ {
+ bool b = Convert.ToBoolean(parameter);
+ if (b)
+ {
+ setter.Value = 100;
+ }
+ else
+ {
+ setter.Value = 200;
+ }
+ }
+
+ #endregion
+ }
+}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/OneZeroBoolTypeHandlerCallback.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/OneZeroBoolTypeHandlerCallback.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/OneZeroBoolTypeHandlerCallback.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/OneZeroBoolTypeHandlerCallback.cs Sun May 15 09:04:04 2005
@@ -1,5 +1,5 @@
using System;
-
+using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.TypeHandlers;
namespace IBatisNet.DataMapper.Test.Domain
@@ -26,7 +26,7 @@
}
else
{
- throw new Exception("Unexpected value " + nullValue + " found where "+TRUE+" or "+FALSE+" was expected.");
+ throw new DataMapperException("Unexpected value " + nullValue + " found where "+TRUE+" or "+FALSE+" was expected.");
}
}
@@ -43,7 +43,7 @@
}
else
{
- throw new Exception("Unexpected value " + i + " found where "+TRUE+" or "+FALSE+" was expected.");
+ throw new DataMapperException("Unexpected value " + i + " found where "+TRUE+" or "+FALSE+" was expected.");
}
}
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=170230&r1=170229&r2=170230&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 15 09:04:04 2005
@@ -233,6 +233,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Domain\HundredsTypeHandlerCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Domain\LineItem.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Account.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Account.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Account.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Account.xml Sun May 15 09:04:04 2005
@@ -20,12 +20,18 @@
</cacheModels>
+ <alias>
+ <typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
+
<resultMaps>
<resultMap id="account-result" class="Account" >
<result property="Id" column="Account_ID"/>
<result property="FirstName" column="Account_FirstName"/>
<result property="LastName" column="Account_LastName"/>
<result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
+ <result property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</resultMap>
<resultMap id="indexed-account-result" class="Account">
<result property="Id" column="Account_ID" columnIndex="0"/>
@@ -146,7 +152,9 @@
Account_ID,
Account_FirstName,
Account_LastName,
- Account_Email
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
from Accounts
where Account_ID = #value#
</select>
@@ -222,7 +230,7 @@
</select>
<select id="GetAccountViaInlineParameters"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -263,9 +271,9 @@
<insert id="InsertAccountViaParameterMap"
parameterMap="insert-params">
insert into Accounts
- (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
values
- (?, ?, ?, ?)
+ (?, ?, ?, ?, ?, ?)
</insert>
<update id="UpdateAccountViaParameterMap"
@@ -314,7 +322,7 @@
<!-- Dynamic statements -->
<select id="GetAllAccountsViaResultMapWithDynamicElement"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select * from Accounts
where Account_Email $value$ '%@%'
order by Account_ID
@@ -379,7 +387,7 @@
<!-- Extends statement -->
<select id="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -390,20 +398,20 @@
<select id="GetAllAccountsOrderByName"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
order by Account_FirstName
</select>
<select id="GetOneAccount"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID = #value#
</select>
<select id="GetSomeAccount"
extends="GetAllAccounts"
parameterClass="Hashtable"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID between #lowID# and #hightID#
</select>
@@ -434,7 +442,7 @@
<select id="GetAccountWithRepeatingProperty"
parameterClass="Account"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -448,6 +456,12 @@
Account_ID = #Id#
</select>
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_ID
+ </select>
+
<!-- For procedure, the parameters of the parameterMap must in the same order
as for the procedure paramaters-->
<procedure id="InsertAccountViaStoreProcedure" parameterMap="insert-params">
@@ -483,6 +497,8 @@
<parameter property="FirstName" />
<parameter property="LastName" />
<parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOption" dbType="Varchar" type="bool"/>
+ <parameter property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</parameterMap>
<parameterMap id="update-params">
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml Sun May 15 09:04:04 2005
@@ -322,7 +322,7 @@
<select id="GetAccountJIRA45"
parameterClass="int"
- resultMap="Account.account-result">
+ resultMap="Account.indexed-account-result">
select
Account_ID,
Account_FirstName,
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml Sun May 15 09:04:04 2005
@@ -19,13 +19,19 @@
</cacheModel> -->
</cacheModels>
-
+
+ <alias>
+ <typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
+
<resultMaps>
<resultMap id="account-result" class="Account" >
<result property="Id" column="Account_ID"/>
<result property="FirstName" column="Account_FirstName"/>
<result property="LastName" column="Account_LastName"/>
<result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
+ <result property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</resultMap>
<resultMap id="indexed-account-result" class="Account">
<result property="Id" column="Account_ID" columnIndex="0"/>
@@ -146,7 +152,9 @@
Account_ID,
Account_FirstName,
Account_LastName,
- Account_Email
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
from Accounts
where Account_ID = #value#
</select>
@@ -222,7 +230,7 @@
</select>
<select id="GetAccountViaInlineParameters"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -263,9 +271,9 @@
<insert id="InsertAccountViaParameterMap"
parameterMap="insert-params">
insert into Accounts
- (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
values
- (?, ?, ?, ?)
+ (?, ?, ?, ?, ?, ?)
</insert>
<update id="UpdateAccountViaParameterMap"
@@ -379,7 +387,7 @@
<!-- Extends statement -->
<select id="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -390,20 +398,20 @@
<select id="GetAllAccountsOrderByName"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
order by Account_FirstName
</select>
<select id="GetOneAccount"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID = #value#
</select>
<select id="GetSomeAccount"
extends="GetAllAccounts"
parameterClass="Hashtable"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID between #lowID# and #hightID#
</select>
@@ -434,7 +442,7 @@
<select id="GetAccountWithRepeatingProperty"
parameterClass="Account"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -448,6 +456,12 @@
Account_ID = #Id#
</select>
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_ID
+ </select>
+
<!-- For procedure, the parameters of the parameterMap must in the same order
as for the procedure paramaters-->
<procedure id="InsertAccountViaStoreProcedure" parameterMap="insert-params">
@@ -483,6 +497,8 @@
<parameter property="FirstName" />
<parameter property="LastName" />
<parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOption" dbType="Varchar" type="bool"/>
+ <parameter property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</parameterMap>
<parameterMap id="update-params">
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml Sun May 15 09:04:04 2005
@@ -321,7 +321,7 @@
<select id="GetAccountJIRA45"
parameterClass="int"
- resultMap="Account.account-result">
+ resultMap="Account.indexed-account-result">
select
Account_ID,
Account_FirstName,
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml Sun May 15 09:04:04 2005
@@ -63,6 +63,10 @@
</cacheModels>
+ <alias>
+ <typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
+
<resultMaps>
<resultMap id="account-result" class="Account" >
@@ -70,8 +74,8 @@
<result property="FirstName" column="Account_FirstName"/>
<result property="LastName" column="Account_LastName"/>
<result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
- <!--<result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="boolean"/>
- <result property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>-->
+ <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
+ <result property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</resultMap>
<resultMap id="indexed-account-result" class="Account">
@@ -194,7 +198,9 @@
Account_ID,
Account_FirstName,
Account_LastName,
- Account_Email
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
from Accounts
where Account_ID = #value#
</select>
@@ -270,7 +276,7 @@
</select>
<select id="GetAccountViaInlineParameters"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -311,9 +317,9 @@
<insert id="InsertAccountViaParameterMap"
parameterMap="insert-params">
insert into Accounts
- (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
values
- (?, ?, ?, ?)
+ (?, ?, ?, ?, ?, ?)
</insert>
<update id="UpdateAccountViaParameterMap"
@@ -428,7 +434,7 @@
<!-- Extends statement -->
<select id="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -439,20 +445,20 @@
<select id="GetAllAccountsOrderByName"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
order by Account_FirstName
</select>
<select id="GetOneAccount"
extends="GetAllAccounts"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID = #value#
</select>
<select id="GetSomeAccount"
extends="GetAllAccounts"
parameterClass="Hashtable"
- resultMap="account-result">
+ resultMap="indexed-account-result">
where Account_ID between #lowID# and #hightID#
</select>
@@ -483,7 +489,7 @@
<select id="GetAccountWithRepeatingProperty"
parameterClass="Account"
- resultMap="account-result">
+ resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
@@ -495,7 +501,13 @@
Account_FirstName = #FirstName# and
Account_LastName = #LastName# and
Account_ID = #Id#
- </select>
+ </select>
+
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_ID
+ </select>
<!-- For procedure, the parameters of the parameterMap must in the same order
as for the procedure paramaters-->
@@ -532,6 +544,8 @@
<parameter property="FirstName" />
<parameter property="LastName" />
<parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOption" dbType="Varchar" type="bool"/>
+ <parameter property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</parameterMap>
<parameterMap id="update-params">
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Enumeration.xml Sun May 15 09:04:04 2005
@@ -9,9 +9,9 @@
<resultMaps>
<resultMap id="enumeration-result" class="Enumeration" >
<result property="Id" column="Enum_ID"/>
- <result property="Day" column="Enum_Day"/>
- <result property="Color" column="Enum_Color"/>
- <result property="Month" column="Enum_Month" nullValue="All"/>
+ <result property="Day" column="Enum_Day"/>
+ <result property="Color" column="Enum_Color"/>
+ <result property="Month" column="Enum_Month" nullValue="All"/>
</resultMap>
</resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml Sun May 15 09:04:04 2005
@@ -332,7 +332,7 @@
<select id="GetAccountJIRA45"
parameterClass="int"
- resultMap="Account.account-result">
+ resultMap="Account.indexed-account-result">
select
Account_ID,
Account_FirstName,
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=170230&r1=170229&r2=170230&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 15 09:04:04 2005
@@ -56,24 +56,6 @@
}
/// <summary>
- /// Test JIRA 30 (repeating property)
- /// TODO JIRA 30 repeating property for all providers
- /// </summary>
- [Test]
- public void TestJIRA30()
- {
- Account account = new Account();
- account.Id = 1;
- account.FirstName = "Joe";
- account.LastName = "Dalton";
- account.EmailAddress = "Joe.Dalton@somewhere.com";
-
- Account result = sqlMap.QueryForObject("GetAccountWithRepeatingProperty", account) as Account;
-
- AssertAccount1(result);
- }
-
- /// <summary>
/// Test ExecuteQueryForObject Via ColumnName
/// </summary>
[Test]
@@ -858,7 +840,7 @@
sqlMap.Insert("InsertAccountViaInlineParameters", account);
- Account testAccount = sqlMap.QueryForObject("GetAccountViaColumnName", 10) as Account;
+ Account testAccount = sqlMap.QueryForObject("GetAccountViaColumnIndex", 10) as Account;
Assert.IsNotNull(testAccount);
Assert.AreEqual(10, testAccount.Id);
@@ -1013,6 +995,8 @@
Assert.IsTrue(rowNumber == 4);
}
+
+
#endregion
#region Row delegate
@@ -1069,6 +1053,24 @@
#region JIRA Tests
/// <summary>
+ /// Test JIRA 30 (repeating property)
+ /// TODO JIRA 30 repeating property for all providers
+ /// </summary>
+ [Test]
+ public void TestJIRA30()
+ {
+ Account account = new Account();
+ account.Id = 1;
+ account.FirstName = "Joe";
+ account.LastName = "Dalton";
+ account.EmailAddress = "Joe.Dalton@somewhere.com";
+
+ Account result = sqlMap.QueryForObject("GetAccountWithRepeatingProperty", account) as Account;
+
+ AssertAccount1(result);
+ }
+
+ /// <summary>
/// Test Bit column
/// </summary>
[Test]
@@ -1096,6 +1098,35 @@
#endregion
#region CustomTypeHandler tests
+
+ /// <summary>
+ /// Test CustomTypeHandler
+ /// </summary>
+ [Test]
+ public void TestExecuteQueryWithCustomTypeHandler()
+ {
+ IList list = sqlMap.QueryForList("GetAllAccountsViaCustomTypeHandler", null);
+
+ AssertAccount1((Account) list[0]);
+ Assert.AreEqual(5, list.Count);
+ Assert.AreEqual(1, ((Account) list[0]).Id);
+ Assert.AreEqual(2, ((Account) list[1]).Id);
+ Assert.AreEqual(3, ((Account) list[2]).Id);
+ Assert.AreEqual(4, ((Account) list[3]).Id);
+ Assert.AreEqual(5, ((Account) list[4]).Id);
+
+ Assert.IsFalse(((Account) list[0]).CartOption);
+ Assert.IsFalse(((Account) list[1]).CartOption);
+ Assert.IsTrue(((Account) list[2]).CartOption);
+ Assert.IsTrue(((Account) list[3]).CartOption);
+ Assert.IsTrue(((Account) list[4]).CartOption);
+
+ Assert.IsTrue(((Account) list[0]).BannerOption);
+ Assert.IsTrue(((Account) list[1]).BannerOption);
+ Assert.IsFalse(((Account) list[2]).BannerOption);
+ Assert.IsFalse(((Account) list[3]).BannerOption);
+ Assert.IsTrue(((Account) list[4]).BannerOption);
+ }
/// <summary>
/// Test CustomTypeHandler Oui/Non
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql Sun May 15 09:04:04 2005
@@ -14,7 +14,9 @@
[Account_ID] [int] NOT NULL ,
[Account_FirstName] [varchar] (32) NOT NULL ,
[Account_LastName] [varchar] (32) NOT NULL ,
- [Account_Email] [varchar] (128) NULL
+ [Account_Email] [varchar] (128) NULL,
+ [Account_Banner_Option] [varchar] (255),
+ [Account_Cart_Option] [int]
) ON [PRIMARY]
ALTER TABLE [dbo].[Accounts] WITH NOCHECK ADD
@@ -25,11 +27,11 @@
-- Creating Test Data
-INSERT INTO [dbo].[Accounts] VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com');
-INSERT INTO [dbo].[Accounts] VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com');
-INSERT INTO [dbo].[Accounts] VALUES(3,'William', 'Dalton', null);
-INSERT INTO [dbo].[Accounts] VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com');
-INSERT INTO [dbo].[Accounts] VALUES(5,'Gilles', 'Bayon', null);
+INSERT INTO [dbo].[Accounts] VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(3,'William', 'Dalton', null, 'Non', 100);
+INSERT INTO [dbo].[Accounts] VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100);
+INSERT INTO [dbo].[Accounts] VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100);
-- Store procedure
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-procedure.sql
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-procedure.sql?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-procedure.sql (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-procedure.sql Sun May 15 09:04:04 2005
@@ -2,9 +2,11 @@
@Account_ID [int],
@Account_FirstName [nvarchar] (40),
@Account_LastName [varchar] (32),
-@Account_Email [varchar] (128)
+@Account_Email [varchar] (128),
+@Account_Banner_Option [varchar] (255),
+@Account_Cart_Option [int]
AS
insert into Accounts
- (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
values
- (@Account_ID, @Account_FirstName, @Account_LastName, @Account_Email)
+ (@Account_ID, @Account_FirstName, @Account_LastName, @Account_Email, @Account_Banner_Option, @Account_Cart_Option)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config Sun May 15 09:04:04 2005
@@ -21,7 +21,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config Sun May 15 09:04:04 2005
@@ -22,7 +22,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config Sun May 15 09:04:04 2005
@@ -22,8 +22,9 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
+
<sqlMaps>
<sqlMap resource="../../Maps/MSSQL/OleDb/Account.xml"/>
<sqlMap resource="../../Maps/MSSQL/OleDb/DynamicAccount.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Sun May 15 09:04:04 2005
@@ -26,7 +26,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config Sun May 15 09:04:04 2005
@@ -23,7 +23,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config Sun May 15 09:04:04 2005
@@ -23,7 +23,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config Sun May 15 09:04:04 2005
@@ -23,7 +23,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config Sun May 15 09:04:04 2005
@@ -23,7 +23,7 @@
</alias>
<typeHandlers>
- <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
<sqlMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt Sun May 15 09:04:04 2005
@@ -11,11 +11,11 @@
- Added typeHandler attribute to result-property and parameter-property tags
- Added <discriminator> and <subMap> tags for class inheritance support
- Added nunit category 'NHibernate'
-- Fixed Oracle issues (JIRA-27, JIRA-56, JIRA-54)
+- Fixed Oracle issues (JIRA-27, JIRA-54, JIRA-56, JIRA-57)
- Fixed JIRA-60 QueryForMap not calling session.CloseConnection() correctly
- Fixed JIRA-51 If a <statement> has a "cacheModel" attribute set and cacheModelsEnabled="false" in SqlMap.config, an DataMapperException is thrown
- Fixed JIRA-49 Exceptions such as NotSupportedException not handled gracefully in CreateParametersForStatementText()
-- Fixed JIRA-47/48 providers.config Assumes Types Are In The Same Assembly
+- Fixed JIRA-47/48/49 providers.config Assumes Types Are In The Same Assembly
- Fixed JIRA-45 Unable to reference result maps defined in other xml files when useStatementNamespaces is set to true
- Fixed JIRA-42 Build 1.1.458.0 doesn't automatically map .Net's bool to Sql Server 2000's Bit column type like previous builds did.
- Fixed JIRA-38 ParseGlobalProperties raises NullReferenceException if optional "properties" element is missing from sqlmap config file
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=170230&r1=170229&r2=170230&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 15 09:04:04 2005
@@ -193,7 +193,7 @@
// Fix JIRA 20
//parameterCopy.Value = parameterValue;
- property.TypeHandler.SetParameter(property, parameterCopy, parameterValue);
+ property.TypeHandler.SetParameter(property, parameterCopy, parameterValue, property.DbType);
#region Logging
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Sun May 15 09:04:04 2005
@@ -280,13 +280,13 @@
if (configScope.TypeHandlerFactory.IsSimpleType(type))
{
// Primitive
- _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type, _dbType);
}
else
{
// .NET object
type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
- _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type, _dbType);
}
}
}
@@ -305,7 +305,7 @@
_direction = (ParameterDirection)Enum.Parse( typeof(ParameterDirection), _directionAttribute, true );
}
- errorContext.MoreInfo = "Intialize an inline parameter property '" + this.PropertyName + "' .";
+ errorContext.MoreInfo = "Initialize an inline parameter property '" + this.PropertyName + "' .";
if (this.CLRType.Length == 0 ) // Unknown
{
_typeHandler = typeHandlerFactory.GetUnkownTypeHandler();
@@ -317,13 +317,13 @@
if (typeHandlerFactory.IsSimpleType(type))
{
// Primitive
- _typeHandler = typeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(type, null);
}
else
{
// .NET object
type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
- _typeHandler = typeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(type, null);
}
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs Sun May 15 09:04:04 2005
@@ -174,7 +174,8 @@
/// Initilaize the underlying mapping
/// </summary>
/// <param name="configScope"></param>
- public void SetMapping(ConfigurationScope configScope)
+ /// <param name="resultClass"></param>
+ public void SetMapping(ConfigurationScope configScope, Type resultClass)
{
configScope.ErrorContext.MoreInfo = "Initialize discriminator mapping";
_mapping = new ResultProperty();
@@ -185,7 +186,7 @@
_mapping.DbType = _dbType;
_mapping.NullValue = _nullValue;
- _mapping.Initialize( configScope, null );
+ _mapping.Initialize( configScope, resultClass );
}
/// <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=170230&r1=170229&r2=170230&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 15 09:04:04 2005
@@ -217,14 +217,14 @@
mapping = (ResultProperty) serializer.Deserialize(new XmlNodeReader(resultNode));
configScope.ErrorContext.MoreInfo = "initialize result property :"+mapping.PropertyName;
-
- PropertyInfo propertyInfo = null;
-
- if ( mapping.PropertyName != "value" && !typeof(IDictionary).IsAssignableFrom(_class) )
- {
- propertyInfo = ReflectionInfo.GetInstance(_class).GetSetter( mapping.PropertyName );
- }
- mapping.Initialize( configScope, propertyInfo );
+//
+// PropertyInfo propertyInfo = null;
+//
+// if ( mapping.PropertyName != "value" && !typeof(IDictionary).IsAssignableFrom(_class) )
+// {
+// propertyInfo = ReflectionInfo.GetInstance(_class).GetSetter( mapping.PropertyName );
+// }
+ mapping.Initialize( configScope, _class );
this.AddResultPropery( mapping );
}
@@ -240,7 +240,7 @@
this.Discriminator = (Discriminator) serializer.Deserialize(new XmlNodeReader(discriminatorNode));
- this.Discriminator.SetMapping( configScope );
+ this.Discriminator.SetMapping( configScope, _class );
}
#endregion
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=170230&r1=170229&r2=170230&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 15 09:04:04 2005
@@ -26,9 +26,11 @@
#region Imports
using System;
+using System.Collections;
using System.Reflection;
using System.Xml.Serialization;
using IBatisNet.Common.Exceptions;
+using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
using IBatisNet.Common.Utilities;
@@ -58,7 +60,7 @@
[NonSerialized]
private string _nullValue = string.Empty;
[NonSerialized]
- private string _property = string.Empty;
+ private string _propertyName = string.Empty;
[NonSerialized]
private string _columnName = string.Empty;
[NonSerialized]
@@ -191,8 +193,8 @@
[XmlAttribute("property")]
public string PropertyName
{
- get { return _property; }
- set { _property = value; }
+ get { return _propertyName; }
+ set { _propertyName = value; }
}
/// <summary>
@@ -249,25 +251,18 @@
/// <summary>
/// Initialize the PropertyInfo of the result property.
/// </summary>
- /// <param name="propertyInfo">A PropertyInfoot.</param>
+ /// <param name="resultClass"></param>
/// <param name="configScope"></param>
- public void Initialize( ConfigurationScope configScope, PropertyInfo propertyInfo )
+ public void Initialize( ConfigurationScope configScope, Type resultClass )
{
- _propertyInfo = propertyInfo;
-
- if ( propertyInfo != null)
- {
- _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
- }
- // If we specify a type, it can overrride
- if (this.CLRType.Length>0)
+ if ( _propertyName.Length>0 &&_propertyName != "value" && !typeof(IDictionary).IsAssignableFrom(resultClass) )
{
- _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
+ _propertyInfo = ReflectionInfo.GetInstance(resultClass).GetSetter( _propertyName );
}
- // 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).";
+ configScope.ErrorContext.MoreInfo = "Result property '"+_propertyName+"' check the typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
try
{
Type type = configScope.SqlMapper.GetType(this.CallBackName);
@@ -279,6 +274,35 @@
throw new ConfigurationException("Error occurred during custom type handler configuration. Cause: " + e.Message, e);
}
}
+ else
+ {
+ configScope.ErrorContext.MoreInfo = "Result property '"+_propertyName+"' set the typeHandler attribute.";
+ _typeHandler = configScope.ResolveTypeHandler( resultClass, _propertyName, _clrType, _dbType);
+ }
+// if ( propertyInfo != null)
+// {
+// _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+// }
+// // If we specify a type, it can overrride
+// if (this.CLRType.Length>0)
+// {
+// _typeHandler = configScope.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>
@@ -291,7 +315,7 @@
{
_propertyInfo = propertyInfo;
- _typeHandler = typeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType, null);
}
#endregion
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Sun May 15 09:04:04 2005
@@ -408,7 +408,7 @@
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = 0;
- property.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(outObject.GetType());
+ property.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(outObject.GetType(), null);
SetObjectProperty(request, request.ResultMap, property, ref outObject, reader);
}
@@ -469,7 +469,7 @@
{
Type propertyType =ObjectProbe.GetPropertyTypeForGetter(result,mapping.PropertyName);
- mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(propertyType);
+ mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(propertyType, null);
}
}
}
@@ -850,7 +850,7 @@
if ( (_statement.ResultClass!=null) &&
_sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass) )
{
- ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
+ ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass, null);
generatedKey = typeHandler.GetDataBaseValue(generatedKey, _statement.ResultClass);
}
}
@@ -1065,7 +1065,7 @@
}
Type systemType =((IDataRecord)reader).GetFieldType(columnIndex);
- mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(systemType);
+ mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(systemType, null);
}
}
}
@@ -1327,7 +1327,7 @@
// Set TypeHandler
Type propertyType = reflectionInfo.GetSetterType(property.PropertyName);
- property.TypeHandler = typeHandlerFactory.GetTypeHandler( propertyType );
+ property.TypeHandler = typeHandlerFactory.GetTypeHandler( propertyType, null );
}
}
catch (Exception e)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Sun May 15 09:04:04 2005
@@ -26,9 +26,14 @@
#region Using
+using System;
+using System.Collections;
using System.Collections.Specialized;
+using System.Configuration;
using System.Xml;
using IBatisNet.Common;
+using IBatisNet.Common.Utilities;
+using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -321,5 +326,89 @@
}
#endregion
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="clazz">Type of the ResultMap</param>
+ /// <param name="propertyName">Property name to map</param>
+ /// <param name="clrType"></param>
+ /// <param name="dbType"></param>
+ /// <returns></returns>
+ public ITypeHandler ResolveTypeHandler(Type clazz, string propertyName, string clrType, string dbType)
+ {
+ ITypeHandler handler = null;
+ if (clazz==null)
+ {
+ handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
+ }
+ else if (typeof(IDictionary).IsAssignableFrom(clazz))
+ {
+ // IDictionary
+ if (clrType.Length == 0)
+ {
+ handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
+ }
+ else
+ {
+ try
+ {
+ Type type = Resources.TypeForName(clrType);
+ handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e);
+ }
+ }
+ }
+ else if (this.TypeHandlerFactory.GetTypeHandler(clazz, dbType) != null)
+ {
+ // Primitive
+ handler = this.TypeHandlerFactory.GetTypeHandler(clazz, dbType);
+ }
+ else
+ {
+ // .NET object
+ if (clrType.Length == 0)
+ {
+ Type type = ObjectProbe.GetPropertyTypeForGetter(clazz, propertyName);
+ handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+ }
+ else
+ {
+ try
+ {
+ Type type = Resources.TypeForName(clrType);
+ handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e);
+ }
+ }
+ }
+// if (clrType.Length == 0 ) // Unknown
+// {
+// handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
+// }
+// else // If we specify a CLR type, use it
+// {
+// Type type = Resources.TypeForName(clrType);
+//
+// if (this.TypeHandlerFactory.IsSimpleType(type))
+// {
+// // Primitive
+// handler = this.TypeHandlerFactory.GetTypeHandler(type);
+// }
+// else
+// {
+// // .NET object
+// type = ObjectProbe.GetPropertyTypeForGetter(type, propertyName);
+// handler = this.TypeHandlerFactory.GetTypeHandler(type);
+// }
+// }
+ return handler;
+ }
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs Sun May 15 09:04:04 2005
@@ -93,7 +93,8 @@
/// <param name="mapping">The mapping between data parameter and object property.</param>
/// <param name="dataParameter"></param>
/// <param name="parameterValue">The value to be set</param>
- public virtual void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+ /// <param name="dbType">Data base type</param>
+ public virtual void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue, string dbType)
{
if (parameterValue!=null)
{
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs Sun May 15 09:04:04 2005
@@ -52,7 +52,8 @@
/// <param name="mapping">The mapping between data parameter and object property.</param>
/// <param name="dataParameter"></param>
/// <param name="parameterValue">The value to be set</param>
- public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+ /// <param name="dbType">Data base type</param>
+ public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue, string dbType)
{
IParameterSetter setter = new ParameterSetterImpl(dataParameter);
_callback.SetParameter(setter, parameterValue);
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs Sun May 15 09:04:04 2005
@@ -68,7 +68,8 @@
/// <param name="mapping">The mapping between data parameter and object property.</param>
/// <param name="dataParameter"></param>
/// <param name="parameterValue">The value to be set</param>
- void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue);
+ /// <param name="dbType">Data base type</param>
+ void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue, string dbType);
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs Sun May 15 09:04:04 2005
@@ -116,16 +116,17 @@
/// Get a TypeHandler for a type
/// </summary>
/// <param name="type">the type you want a TypeHandler for</param>
+ /// <param name="dbType">the database type</param>
/// <returns>the handler</returns>
- public ITypeHandler GetTypeHandler(Type type)
+ public ITypeHandler GetTypeHandler(Type type, string dbType)
{
if (type.IsEnum)
{
- return this.GetTypeHandler(typeof(System.Enum), null);
+ return this.GetPrivateTypeHandler(typeof(System.Enum), dbType);
}
else
{
- return this.GetTypeHandler(type, null);
+ return this.GetPrivateTypeHandler(type, dbType);
}
}
@@ -135,7 +136,7 @@
/// <param name="type">the type</param>
/// <param name="dbType">the dbType type</param>
/// <returns>the handler</returns>
- public ITypeHandler GetTypeHandler(Type type, string dbType)
+ private ITypeHandler GetPrivateTypeHandler(Type type, string dbType)
{
HybridDictionary dbTypeHandlerMap = (HybridDictionary) _typeHandlerMap[ type ];
ITypeHandler handler = null;
@@ -157,8 +158,6 @@
}
return handler;
-
- //return GetTypeHandler(type);
}
@@ -215,7 +214,7 @@
bool result = false;
if (type != null)
{
- ITypeHandler handler = this.GetTypeHandler(type);
+ ITypeHandler handler = this.GetTypeHandler(type, null);
if (handler != null)
{
result = handler.IsSimpleType();
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs?rev=170230&r1=170229&r2=170230&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs Sun May 15 09:04:04 2005
@@ -57,12 +57,13 @@
/// <param name="mapping">The mapping between data parameter and object property.</param>
/// <param name="dataParameter"></param>
/// <param name="parameterValue">The value to be set</param>
- public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+ /// <param name="dbType">Data base type</param>
+ public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue, string dbType)
{
if (parameterValue!=null)
{
- ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType() );
- handler.SetParameter(mapping, dataParameter, parameterValue);
+ ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType(), dbType );
+ handler.SetParameter(mapping, dataParameter, parameterValue, dbType);
}
else
{