You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2006/04/26 22:05:21 UTC
svn commit: r397283 [2/3] - in /ibatis/trunk/cs/mapper: ./
IBatisNet.Common.Test/bin/Debug/ IBatisNet.DataAccess.Test/bin/Debug/
IBatisNet.DataMapper.Test/ IBatisNet.DataMapper.Test/Domain/
IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/ IBatisNet.DataMappe...
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml Wed Apr 26 13:05:17 2006
@@ -72,9 +72,20 @@
</cacheModels>
- <resultMaps>
-
- <resultMap id="account-result" class="Account" >
+ <resultMaps>
+
+ <resultMap id="account-result-constructor" class="Account" >
+ <constructor>
+ <argument argumentName="id" column="Account_ID"/>
+ <argument argumentName="firstName" column="Account_FirstName"/>
+ <argument argumentName="lastName" column="Account_LastName"/>
+ </constructor>
+ <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="account-result" class="Account" >
<result property="_id" column="Account_ID"/>
<result property="FirstName" column="Account_FirstName"/>
<result property="LastName" column="Account_LastName"/>
@@ -82,12 +93,12 @@
<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"/>
- <result property="FirstName" column="Account_FirstName" columnIndex="1"/>
- <result property="LastName" column="Account_LastName" columnIndex="2"/>
- <result property="EmailAddress" column="Account_Email" columnIndex="3" nullValue="no_email@provided.com"/>
+
+ <resultMap id="indexed-account-result" class="Account">
+ <result property="Id" columnIndex="0"/>
+ <result property="FirstName" columnIndex="1"/>
+ <result property="LastName" columnIndex="2"/>
+ <result property="EmailAddress" columnIndex="3" nullValue="no_email@provided.com"/>
</resultMap>
<resultMap id="account-result-nullable-email" class="Account">
@@ -116,6 +127,13 @@
-->
<statements>
+ <select id="SelectAccountConstructor" parameterClass="Integer"
+ resultMap="account-result-constructor">
+ select *
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
<select id="GetAccountsDynamic" resultMap="account-result" parameterClass="Hashtable" >
select top $MaximumAllowed$ * from Accounts
<dynamic prepend="where">
@@ -277,7 +295,6 @@
where Account_ID > 1000
order by Account_ID
</select>
-
<select id="GetAccountNullableEmail"
resultMap="account-result-nullable-email">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Nullable.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Nullable.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Nullable.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Nullable.xml Wed Apr 26 13:05:17 2006
@@ -8,6 +8,24 @@
</alias>
<resultMaps>
+
+ <resultMap id="Nullable-result-constructor" class="Nullable" >
+ <constructor>
+ <argument argumentName="id" column="TestInt32"/>
+ </constructor>
+ <result property="Id" column="Id"/>
+ <result property="TestBool" column="TestBool" />
+ <result property="TestByte" column="TestByte" />
+ <result property="TestChar" column="TestChar" />
+ <result property="TestDateTime" column="TestDateTime" />
+ <result property="TestDecimal" column="TestDecimal" />
+ <result property="TestDouble" column="TestDouble" />
+ <result property="TestGuid" column="TestGuid"/>
+ <result property="TestInt16" column="TestInt16"/>
+ <result property="TestInt64" column="TestInt64"/>
+ <result property="TestSingle" column="TestSingle" />
+ </resultMap>
+
<resultMap id="Nullable-result" class="Nullable">
<result property="Id" column="Id"/>
<result property="TestBool" column="TestBool" />
@@ -26,6 +44,13 @@
<statements>
+ <select id="GetNullableConstructor" resultMap="Nullable-result-constructor" >
+ select
+ *
+ from Nullable
+ where Id = #value#
+ </select>
+
<select id="GetNullable" resultMap="Nullable-result" >
select
*
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml Wed Apr 26 13:05:17 2006
@@ -14,13 +14,105 @@
<resultMaps>
- <resultMap id="credit-card-result" class="string">
- <result property="value" column="Order_CardNumber"/>
+ <resultMap id="order-result-constructor1" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" resultMapping="Account.account-result-nullable-email" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor2" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor3" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrder" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor4" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="lineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
</resultMap>
- <resultMap id="lite-order-result-by-name" class="Order">
+ <resultMap id="order-result-constructor5" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor6" class="Order" >
+ <constructor>
+ <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
<result property="Id" column="Order_ID"/>
- <result property="Date" column="Order_Date" nullValue="01/01/0001 00:00:00"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor7" class="Order" >
+ <constructor>
+ <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" column="Order_Date"/>
<result property="CardExpiry" column="Order_CardExpiry"/>
<result property="CardType" column="Order_CardType"/>
<result property="CardNumber" column="Order_CardNumber"/>
@@ -29,44 +121,60 @@
<result property="Province" column="Order_Province"/>
<result property="PostalCode" column="Order_PostalCode"/>
</resultMap>
+
+ <resultMap id="credit-card-result" class="string">
+ <result property="value" column="Order_CardNumber"/>
+ </resultMap>
- <resultMap id="order-with-generic-list-lineitem" class="Order"
- extends="lite-order-result-by-name" >
- <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrder" />
- </resultMap>
+ <resultMap id="lite-order-result-by-name" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" column="Order_Date" nullValue="01/01/0001 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
- <resultMap id="order-with-generic-collection-lineitem" class="Order"
- extends="lite-order-result-by-name" >
- <result property="LineItemsCollection" column="Order_ID" select="GetLineItemsForOrder" />
- </resultMap>
+ <resultMap id="order-with-generic-list-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
- <resultMap id="order-with-generic-collection-via-sp" class="Order"
- extends="lite-order-result-by-name" >
- <result property="LineItemsCollection" column="Order_ID" select="SelectLineItemForOrder" />
- </resultMap>
-
- <resultMap id="order-with-lines-result" class="Order"
+ <resultMap id="order-with-generic-collection-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-generic-collection-via-sp" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection" column="Order_ID" select="SelectLineItemForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result" class="Order"
extends="lite-order-result-by-name" >
- <result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
- </resultMap>
+ <result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
- <resultMap id="order-with-lines-result-statement-namespaces" class="Order"
+ <resultMap id="order-with-lines-result-statement-namespaces" class="Order"
extends="lite-order-result-by-name" >
- <result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="LineItem.GetLineItemsForOrder" />
- </resultMap>
+ <result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="LineItem.GetLineItemsForOrder" />
+ </resultMap>
- <resultMap id="order-with-lines-collection" class="Order"
+ <resultMap id="order-with-lines-collection" class="Order"
extends="lite-order-result-by-name" >
- <result property="LineItems" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass" />
- </resultMap>
+ <result property="LineItems" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
- <resultMap id="order-with-lines-array" class="Order"
+ <resultMap id="order-with-lines-array" class="Order"
extends="lite-order-result-by-name">
- <result property="LineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
- </resultMap>
+ <result property="LineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
+ </resultMap>
- <resultMap id="lite-order-map-result" class="Hashtable">
- <result property="Id" type="Int" column="Order_ID"/>
+ <resultMap id="lite-order-map-result" class="Hashtable">
+ <result property="Id" type="Int" column="Order_ID"/>
<result property="Date" type="date" column="Order_Date"/>
<result property="CardExpiry" type="string" column="Order_CardExpiry"/>
<result property="CardType" type="string" column="Order_CardType"/>
@@ -231,24 +339,23 @@
</select>-->
- <statement id="GetOrderWithGenericListLineItem"
- parameterClass="Integer"
- resultMap="order-with-generic-list-lineitem" >
- select * from Orders where Order_ID = #value#
- </statement>
-
- <statement id="GetOrderWithGenericLineItemCollection"
- parameterClass="Integer"
- resultMap="order-with-generic-collection-lineitem" >
- select * from Orders where Order_ID = #value#
- </statement>
-
- <statement id="GetOrderWithGenericViaSP"
- parameterClass="Integer"
- resultMap="order-with-generic-collection-via-sp" >
- select * from Orders where Order_ID = #value#
- </statement>
+ <statement id="GetOrderWithGenericListLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-generic-list-lineitem" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithGenericLineItemCollection"
+ parameterClass="Integer"
+ resultMap="order-with-generic-collection-lineitem" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetOrderWithGenericViaSP"
+ parameterClass="Integer"
+ resultMap="order-with-generic-collection-via-sp" >
+ select * from Orders where Order_ID = #value#
+ </statement>
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
@@ -290,11 +397,11 @@
select * from Orders where Order_ID = #value#
</statement>
- <statement id="GetOrderWithGenricListLineItem"
- parameterClass="Integer"
- resultMap="order-with-generic-list-lineitem" >
- select * from Orders where Order_ID = #value#
- </statement>
+ <statement id="GetOrderWithGenricListLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-generic-list-lineitem" >
+ select * from Orders where Order_ID = #value#
+ </statement>
<statement id="GetOrderWithLineItemsUsingStatementNamespaces"
parameterClass="Integer"
@@ -484,8 +591,67 @@
from Orders as ord
LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
where Order_ID = #value#
+ </select>
+
+ <select id="GetOrderConstructor1"
+ parameterClass="Integer"
+ resultMap="order-result-constructor1">
+ select
+ Order_ID,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode,
+ acc.Account_ID,
+ acc.Account_FirstName,
+ acc.Account_LastName,
+ acc.Account_Email
+ from Orders as ord
+ LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
+ where Order_ID = #value#
</select>
- </statements>
+
+ <statement id="GetOrderConstructor2"
+ parameterClass="int"
+ resultMap="order-result-constructor2">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor3"
+ parameterClass="int"
+ resultMap="order-result-constructor3">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor4"
+ parameterClass="int"
+ resultMap="order-result-constructor4">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor5"
+ parameterClass="int"
+ resultMap="order-result-constructor5">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor6"
+ parameterClass="int"
+ resultMap="order-result-constructor6">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor7"
+ parameterClass="int"
+ resultMap="order-result-constructor7">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ </statements>
<parameterMaps>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml Wed Apr 26 13:05:17 2006
@@ -74,7 +74,19 @@
<typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
- <resultMaps>
+ <resultMaps>
+
+ <resultMap id="account-result-constructor" class="Account" >
+ <constructor>
+ <argument argumentName="id" column="Account_ID"/>
+ <argument argumentName="firstName" column="Account_FirstName"/>
+ <argument argumentName="lastName" column="Account_LastName"/>
+ </constructor>
+ <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOption" column="Account_Banner_Option" dbType="Text" type="bool"/>
+ <result property="CartOption" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </resultMap>
+
<resultMap id="account-result" class="Account" >
<result property="Id" column="Account_ID"/>
<result property="FirstName" column="Account_FirstName"/>
@@ -114,7 +126,14 @@
=============================================
-->
<statements>
-
+
+ <select id="SelectAccountConstructor" parameterClass="Integer"
+ resultMap="account-result-constructor">
+ select *
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
<select id="GetAllAccountsCache"
resultMap="account-result"
cacheModel="account-cache">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Nullable.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Nullable.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Nullable.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Nullable.xml Wed Apr 26 13:05:17 2006
@@ -8,6 +8,24 @@
</alias>
<resultMaps>
+
+ <resultMap id="Nullable-result-constructor" class="Nullable" >
+ <constructor>
+ <argument argumentName="id" column="TestInt32"/>
+ </constructor>
+ <result property="Id" column="Id"/>
+ <result property="TestBool" column="TestBool" />
+ <result property="TestByte" column="TestByte" />
+ <result property="TestChar" column="TestChar" />
+ <result property="TestDateTime" column="TestDateTime" />
+ <result property="TestDecimal" column="TestDecimal" />
+ <result property="TestDouble" column="TestDouble" />
+ <result property="TestGuid" column="TestGuid"/>
+ <result property="TestInt16" column="TestInt16"/>
+ <result property="TestInt64" column="TestInt64"/>
+ <result property="TestSingle" column="TestSingle" />
+ </resultMap>
+
<resultMap id="Nullable-result" class="Nullable">
<result property="Id" column="Id"/>
<result property="TestBool" column="TestBool" />
@@ -26,6 +44,13 @@
<statements>
+ <select id="GetNullableConstructor" resultMap="Nullable-result-constructor" >
+ select
+ *
+ from Nullable
+ where Id = #value#
+ </select>
+
<select id="GetNullable" resultMap="Nullable-result" >
select
*
@@ -43,7 +68,8 @@
<insert id="InsertNullable" parameterClass="Nullable" >
<selectKey property="Id" type="post" resultClass="int">
- select SCOPE_IDENTITY() as value
+ SELECT cast(last_value as int) AS value
+ FROM nullable_id_seq
</selectKey>
insert into Nullable
(TestBool, TestByte, TestChar, TestDateTime, TestDecimal, TestDouble, TestGuid, TestInt16, TestInt32, TestInt64, TestSingle)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Order.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Order.xml?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Order.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Order.xml Wed Apr 26 13:05:17 2006
@@ -11,8 +11,116 @@
data provider Type of the Parameter from the Value property
of the Parameter object. -->
- <resultMaps>
-
+ <resultMaps>
+
+ <resultMap id="order-result-constructor1" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" resultMapping="Account.account-result-nullable-email" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor2" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor3" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrder" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor4" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="lineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor5" class="Order" >
+ <constructor>
+ <argument argumentName="id" column="Order_ID"/>
+ <argument argumentName="account" column="Account_ID" select="GetAccountViaColumnName" />
+ <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor6" class="Order" >
+ <constructor>
+ <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-result-constructor7" class="Order" >
+ <constructor>
+ <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </constructor>
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
<resultMap id="credit-card-result" class="string">
<result property="value" column="Order_CardNumber"/>
</resultMap>
@@ -432,9 +540,67 @@
from Orders as ord
LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
where Order_ID = #value#
- </select>
-
- </statements>
+ </select>
+
+ <select id="GetOrderConstructor1"
+ parameterClass="Integer"
+ resultMap="order-result-constructor1">
+ select
+ Order_ID,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode,
+ acc.Account_ID,
+ acc.Account_FirstName,
+ acc.Account_LastName,
+ acc.Account_Email
+ from Orders as ord
+ LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
+ where Order_ID = #value#
+ </select>
+
+ <statement id="GetOrderConstructor2"
+ parameterClass="int"
+ resultMap="order-result-constructor2">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor3"
+ parameterClass="int"
+ resultMap="order-result-constructor3">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor4"
+ parameterClass="int"
+ resultMap="order-result-constructor4">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor5"
+ parameterClass="int"
+ resultMap="order-result-constructor5">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor6"
+ parameterClass="int"
+ resultMap="order-result-constructor6">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderConstructor7"
+ parameterClass="int"
+ resultMap="order-result-constructor7">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ </statements>
<parameterMaps>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs Wed Apr 26 13:05:17 2006
@@ -73,7 +73,9 @@
}
catch(Exception ex)
{
+ Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace.ToString());
+ throw;
}
if ( sqlMap.DataSource.DbProvider.Name.IndexOf("PostgreSql")>=0)
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs?rev=397283&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs Wed Apr 26 13:05:17 2006
@@ -0,0 +1,197 @@
+using System;
+using System.Collections;
+using IBatisNet.Common;
+using IBatisNet.Common.Exceptions;
+using IBatisNet.Common.Utilities;
+using IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.DataMapper.Test.Domain;
+using NUnit.Framework;
+
+namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
+{
+ /// <summary>
+ /// Summary description for ConstructorTest.
+ /// </summary>
+ [TestFixture]
+ public class ConstructorTest : BaseTest
+ {
+ #region SetUp & TearDown
+
+ /// <summary>
+ /// SetUp
+ /// </summary>
+ [SetUp]
+ public void Init()
+ {
+ 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 + "Nullable-init.sql");
+ }
+
+ /// <summary>
+ /// TearDown
+ /// </summary>
+ [TearDown]
+ public void Dispose()
+ { /* ... */
+ }
+
+ #endregion
+
+ #region Tests
+
+ /// <summary>
+ /// Test account constructor mapping
+ /// </summary>
+ [Test]
+ public void TestPrimitiveArgument()
+ {
+ Account account = sqlMap.QueryForObject("SelectAccountConstructor", 1) as Account;
+ AssertAccount1(account);
+ }
+
+#if dotnet2
+ /// <summary>
+ /// Test argument nullable constructor mapping
+ /// </summary>
+ [Test]
+ public void TestNullableArgument()
+ {
+ NullableClass clazz = new NullableClass();
+ clazz.TestBool = true;
+ clazz.TestByte = 155;
+ clazz.TestChar = 'a';
+ DateTime? date = new DateTime?(DateTime.Now);
+ clazz.TestDateTime = date;
+ clazz.TestDecimal = 99.53M;
+ clazz.TestDouble = 99.5125;
+ Guid? guid = new Guid?(Guid.NewGuid());
+ clazz.TestGuid = guid;
+ clazz.TestInt16 = 45;
+ clazz.TestInt32 = null;
+ clazz.TestInt64 = 1234567890123456789;
+ clazz.TestSingle = 4578.46445454112f;
+
+ sqlMap.Insert("InsertNullable", clazz);
+
+ clazz = null;
+ clazz = sqlMap.QueryForObject<NullableClass>("GetNullableConstructor", 1);
+
+ Assert.IsNotNull(clazz);
+ Assert.AreEqual(1, clazz.Id);
+ Assert.IsTrue(clazz.TestBool.Value);
+ Assert.AreEqual(155, clazz.TestByte);
+ Assert.AreEqual('a', clazz.TestChar);
+ Assert.AreEqual(date.Value.ToString(), clazz.TestDateTime.Value.ToString());
+ Assert.AreEqual(99.53M, clazz.TestDecimal);
+ Assert.AreEqual(99.5125, clazz.TestDouble);
+ Assert.AreEqual(guid, clazz.TestGuid);
+ Assert.AreEqual(45, clazz.TestInt16);
+ Assert.IsNull(clazz.TestInt32);
+ Assert.AreEqual(1234567890123456789, clazz.TestInt64);
+ Assert.AreEqual(4578.46445454112f, clazz.TestSingle);
+ }
+#endif
+
+ /// <summary>
+ /// Test constructor with resultMapping attribute on argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentResultMapping()
+ {
+ Order order = sqlMap.QueryForObject("GetOrderConstructor1",10) as Order;
+
+ Assert.IsNotNull(order.Account);
+ AssertAccount1(order.Account);
+
+ order = sqlMap.QueryForObject("GetOrderConstructor1",11) as Order;
+
+ Assert.IsNull(order.Account);
+ }
+
+ /// <summary>
+ /// Test constructor with select attribute on argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectObject()
+ {
+ Order order = (Order) sqlMap.QueryForObject("GetOrderConstructor2", 1);
+ AssertOrder1(order);
+ AssertAccount1(order.Account);
+ }
+
+ /// <summary>
+ /// Test constructor with select attribute on IList argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectIList()
+ {
+ Order order = (Order) sqlMap.QueryForObject("GetOrderConstructor3", 1);
+ AssertOrder1(order);
+ AssertAccount1(order.Account);
+
+ Assert.IsNotNull(order.LineItemsIList);
+ Assert.AreEqual(2, order.LineItemsIList.Count);
+ }
+
+ /// <summary>
+ /// Test constructor with select attribute on array argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectArray()
+ {
+ Order order = (Order) sqlMap.QueryForObject("GetOrderConstructor4", 1);
+ AssertOrder1(order);
+ AssertAccount1(order.Account);
+
+ Assert.IsNotNull( order.LineItemsArray );
+ Assert.AreEqual(2, order.LineItemsArray.Length);
+ }
+
+ /// <summary>
+ /// Test constructor with select attribute on stronly typed collection argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectCollection()
+ {
+ Order order = (Order) sqlMap.QueryForObject("GetOrderConstructor5", 1);
+ AssertOrder1(order);
+ AssertAccount1(order.Account);
+
+ Assert.IsNotNull( order.LineItems );
+ Assert.AreEqual(2, order.LineItems.Count);
+ }
+
+#if dotnet2
+ /// <summary>
+ /// Test constructor with select attribute on generic list argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectGenericIList()
+ {
+ Order order = (Order)sqlMap.QueryForObject("GetOrderConstructor6", 1);
+ AssertOrder1(order);
+
+ Assert.IsNotNull(order.LineItemsGenericList);
+ Assert.AreEqual(2, order.LineItemsGenericList.Count);
+ }
+
+ /// <summary>
+ /// Test constructor with select attribute on stronly typed generic collection argument
+ /// </remarks>
+ [Test]
+ public void TestArgumentSelectGenericCollection()
+ {
+ Order order = (Order)sqlMap.QueryForObject("GetOrderConstructor7", 1);
+ AssertOrder1(order);
+
+ Assert.IsNotNull(order.LineItemsCollection);
+ Assert.AreEqual(2, order.LineItemsCollection.Count);
+ }
+#endif
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/DataBase.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/DataBase.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/DataBase.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/DataBase.sql Wed Apr 26 13:05:17 2006
@@ -1,38 +1,38 @@
-DROP database "IBatisNet";
-DROP database "NHibernate";
-
--- User: "IBatisNet"
-
-DROP USER "IBatisNet";
-
-CREATE USER "IBatisNet" PASSWORD 'test'
- CREATEDB CREATEUSER
- VALID UNTIL 'infinity';
-
--- User: "NHibernate"
-
-DROP USER "NHibernate";
-
-CREATE USER "NHibernate" PASSWORD 'test'
- CREATEDB CREATEUSER
- VALID UNTIL 'infinity';
-
-
--- Database: "IBatisNet"
-
-CREATE DATABASE "IBatisNet"
-WITH ENCODING='UNICODE'
- OWNER="IBatisNet";
-
--- Database: "NHibernate"
-
-CREATE DATABASE "NHibernate"
- WITH ENCODING='UNICODE'
- OWNER="NHibernate";
-
-
-
-
+DROP database "IBatisNet";
+DROP database "NHibernate";
+
+-- User: "IBatisNet"
+
+DROP USER "IBatisNet";
+
+CREATE USER "IBatisNet" PASSWORD 'test'
+ CREATEDB CREATEUSER
+ VALID UNTIL 'infinity';
+
+-- User: "NHibernate"
+
+DROP USER "NHibernate";
+
+CREATE USER "NHibernate" PASSWORD 'test'
+ CREATEDB CREATEUSER
+ VALID UNTIL 'infinity';
+
+
+-- Database: "IBatisNet"
+
+CREATE DATABASE "IBatisNet"
+WITH ENCODING='UNICODE'
+ OWNER="IBatisNet";
+
+-- Database: "NHibernate"
+
+CREATE DATABASE "NHibernate"
+ WITH ENCODING='UNICODE'
+ OWNER="NHibernate";
+
+
+
+
\connect "IBatisNet" "IBatisNet" using test;
-- DROP TABLE Accounts;
@@ -47,130 +47,130 @@
-- DROP TABLE Others;
--- DROP TABLE Documents;
-
-
-
--- Sequence: S_Categories
-
--- DROP SEQUENCE S_Categories;
-
-/*
-CREATE SEQUENCE S_Categories
- INCREMENT 1
- MINVALUE 1
- MAXVALUE 9223372036854775807
- START 1
- CACHE 20;
-ALTER TABLE S_Categories OWNER TO "IBatisNet";
+-- DROP TABLE Documents;
+
+
+
+-- Sequence: S_Categories
+
+-- DROP SEQUENCE S_Categories;
+
+/*
+CREATE SEQUENCE S_Categories
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 20;
+ALTER TABLE S_Categories OWNER TO "IBatisNet";
*/
/*==============================================================*/
/* Table : Accounts */
/*==============================================================*/
-CREATE TABLE Accounts
-(
- Account_Id int4 NOT NULL,
- Account_FirstName varchar(32) NOT NULL,
- Account_LastName varchar(32) NOT NULL,
- Account_Email varchar(128),
+CREATE TABLE Accounts
+(
+ Account_Id int4 NOT NULL,
+ Account_FirstName varchar(32) NOT NULL,
+ Account_LastName varchar(32) NOT NULL,
+ Account_Email varchar(128),
Account_Banner_Option varchar(255),
- Account_Cart_Option int4,
- CONSTRAINT PK_Accounts PRIMARY KEY (Account_Id)
-) WITHOUT OIDS;
+ Account_Cart_Option int4,
+ CONSTRAINT PK_Accounts PRIMARY KEY (Account_Id)
+) WITHOUT OIDS;
ALTER TABLE Accounts OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : Categories */
/*==============================================================*/
-CREATE TABLE Categories
-(
- Category_Id serial,
- Category_Name varchar(32),
- Category_Guid varchar(36),
- CONSTRAINT PK_Categories PRIMARY KEY (Category_Id)
-)
-WITHOUT OIDS;
-ALTER TABLE Categories OWNER TO "IBatisNet";
+CREATE TABLE Categories
+(
+ Category_Id serial,
+ Category_Name varchar(32),
+ Category_Guid varchar(36),
+ CONSTRAINT PK_Categories PRIMARY KEY (Category_Id)
+)
+WITHOUT OIDS;
+ALTER TABLE Categories OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : Enumerations */
/*==============================================================*/
-CREATE TABLE Enumerations
-(
- Enum_Id int4 NOT NULL,
- Enum_Day int4 NOT NULL,
- Enum_Color int4 NOT NULL,
- Enum_Month int4,
- CONSTRAINT PK_Enumerations PRIMARY KEY (Enum_Id)
-)
-WITHOUT OIDS;
+CREATE TABLE Enumerations
+(
+ Enum_Id int4 NOT NULL,
+ Enum_Day int4 NOT NULL,
+ Enum_Color int4 NOT NULL,
+ Enum_Month int4,
+ CONSTRAINT PK_Enumerations PRIMARY KEY (Enum_Id)
+)
+WITHOUT OIDS;
ALTER TABLE Enumerations OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : LineItems */
/*==============================================================*/
-CREATE TABLE LineItems
-(
- LineItem_Id int4 NOT NULL,
- Order_Id int4 NOT NULL,
- LineItem_Code varchar(32) NOT NULL,
- LineItem_Quantity int4 NOT NULL,
- LineItem_Price numeric(18,2),
- LineItem_Picture bytea,
- CONSTRAINT PK_LineItems PRIMARY KEY (LineItem_Id, Order_Id)
-)
-WITHOUT OIDS;
+CREATE TABLE LineItems
+(
+ LineItem_Id int4 NOT NULL,
+ Order_Id int4 NOT NULL,
+ LineItem_Code varchar(32) NOT NULL,
+ LineItem_Quantity int4 NOT NULL,
+ LineItem_Price numeric(18,2),
+ LineItem_Picture bytea,
+ CONSTRAINT PK_LineItems PRIMARY KEY (LineItem_Id, Order_Id)
+)
+WITHOUT OIDS;
ALTER TABLE LineItems OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : Orders */
/*==============================================================*/
-CREATE TABLE Orders
-(
- Order_Id int4 NOT NULL,
- Account_Id int4 NOT NULL,
- Order_Date timestamp,
- Order_CardType varchar(32),
- Order_CardNumber varchar(32),
- Order_CardExpiry varchar(32),
- Order_Street varchar(32),
- Order_City varchar(32),
- Order_Province varchar(32),
- Order_PostalCode varchar(32),
- Order_FavouriteLineItem int4,
- CONSTRAINT PK_Orders PRIMARY KEY (Order_Id)
-)
-WITHOUT OIDS;
-ALTER TABLE Orders OWNER TO "IBatisNet";
+CREATE TABLE Orders
+(
+ Order_Id int4 NOT NULL,
+ Account_Id int4 NOT NULL,
+ Order_Date timestamp,
+ Order_CardType varchar(32),
+ Order_CardNumber varchar(32),
+ Order_CardExpiry varchar(32),
+ Order_Street varchar(32),
+ Order_City varchar(32),
+ Order_Province varchar(32),
+ Order_PostalCode varchar(32),
+ Order_FavouriteLineItem int4,
+ CONSTRAINT PK_Orders PRIMARY KEY (Order_Id)
+)
+WITHOUT OIDS;
+ALTER TABLE Orders OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : Others */
/*==============================================================*/
-CREATE TABLE Others
-(
- Other_Int int4,
- Other_Long int8,
- Other_Bit bool NOT NULL DEFAULT false,
- Other_String varchar(32) NOT NULL
-)
-WITHOUT OIDS;
+CREATE TABLE Others
+(
+ Other_Int int4,
+ Other_Long int8,
+ Other_Bit bool NOT NULL DEFAULT false,
+ Other_String varchar(32) NOT NULL
+)
+WITHOUT OIDS;
ALTER TABLE Others OWNER TO "IBatisNet";
/*==============================================================*/
/* Table : Documents */
/*==============================================================*/
-CREATE TABLE Documents
-(
- Document_Id int4 NOT NULL,
- Document_Title varchar(32),
- Document_Type varchar(32),
- Document_PageNumber int4,
- Document_City varchar(32),
- CONSTRAINT PK_Documents PRIMARY KEY (Document_Id)
-)
-WITHOUT OIDS;
-ALTER TABLE Documents OWNER TO "IBatisNet";
+CREATE TABLE Documents
+(
+ Document_Id int4 NOT NULL,
+ Document_Title varchar(32),
+ Document_Type varchar(32),
+ Document_PageNumber int4,
+ Document_City varchar(32),
+ CONSTRAINT PK_Documents PRIMARY KEY (Document_Id)
+)
+WITHOUT OIDS;
+ALTER TABLE Documents OWNER TO "IBatisNet";
@@ -182,14 +182,14 @@
/*==============================================================*/
/* Table : Users */
/*==============================================================*/
-CREATE TABLE Users
-(
- LogonId varchar(20) NOT NULL DEFAULT '0'::character varying,
- Name varchar(40),
- Password varchar(20),
- EmailAddress varchar(40),
- LastLogon date,
- CONSTRAINT PK_Users PRIMARY KEY (LogonId)
-)
-WITHOUT OIDS;
+CREATE TABLE Users
+(
+ LogonId varchar(20) NOT NULL DEFAULT '0'::character varying,
+ Name varchar(40),
+ Password varchar(20),
+ EmailAddress varchar(40),
+ LastLogon date,
+ CONSTRAINT PK_Users PRIMARY KEY (LogonId)
+)
+WITHOUT OIDS;
ALTER TABLE Users OWNER TO "NHibernate";
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/account-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/account-init.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/account-init.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/account-init.sql Wed Apr 26 13:05:17 2006
@@ -1,19 +1,19 @@
DROP TABLE Accounts;
-
-CREATE TABLE Accounts
-(
- Account_Id int4 NOT NULL,
- Account_FirstName varchar(32) NOT NULL,
- Account_LastName varchar(32) NOT NULL,
- Account_Email varchar(128),
+
+CREATE TABLE Accounts
+(
+ Account_Id int4 NOT NULL,
+ Account_FirstName varchar(32) NOT NULL,
+ Account_LastName varchar(32) NOT NULL,
+ Account_Email varchar(128),
Account_Banner_Option varchar(255),
- Account_Cart_Option int4,
- CONSTRAINT PK_Accounts PRIMARY KEY (Account_Id)
-) WITHOUT OIDS;
-ALTER TABLE Accounts OWNER TO "IBatisNet";
-
+ Account_Cart_Option int4,
+ CONSTRAINT PK_Accounts PRIMARY KEY (Account_Id)
+) WITHOUT OIDS;
+ALTER TABLE Accounts OWNER TO "IBatisNet";
+
INSERT INTO Accounts VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200);
INSERT INTO Accounts VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200);
INSERT INTO Accounts VALUES(3,'William', 'Dalton', null, 'Non', 100);
INSERT INTO Accounts VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100);
-INSERT INTO Accounts VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100);
+INSERT INTO Accounts VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/category-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/category-init.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/category-init.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/category-init.sql Wed Apr 26 13:05:17 2006
@@ -1,11 +1,11 @@
DROP TABLE Categories;
-CREATE TABLE Categories
-(
- Category_Id serial,
- Category_Name varchar(32),
- Category_Guid varchar(36),
- CONSTRAINT PK_Categories PRIMARY KEY (Category_Id)
-)
-WITHOUT OIDS;
+CREATE TABLE Categories
+(
+ Category_Id serial,
+ Category_Name varchar(32),
+ Category_Guid varchar(36),
+ CONSTRAINT PK_Categories PRIMARY KEY (Category_Id)
+)
+WITHOUT OIDS;
ALTER TABLE Categories OWNER TO "IBatisNet";
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/documents-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/documents-init.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/documents-init.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/documents-init.sql Wed Apr 26 13:05:17 2006
@@ -1,15 +1,15 @@
DROP TABLE Documents;
-CREATE TABLE Documents
-(
- Document_Id int4 NOT NULL,
- Document_Title varchar(32),
- Document_Type varchar(32),
- Document_PageNumber int4,
- Document_City varchar(32),
- CONSTRAINT PK_Documents PRIMARY KEY (Document_Id)
-)
-WITHOUT OIDS;
+CREATE TABLE Documents
+(
+ Document_Id int4 NOT NULL,
+ Document_Title varchar(32),
+ Document_Type varchar(32),
+ Document_PageNumber int4,
+ Document_City varchar(32),
+ CONSTRAINT PK_Documents PRIMARY KEY (Document_Id)
+)
+WITHOUT OIDS;
ALTER TABLE Documents OWNER TO "IBatisNet";
INSERT INTO Documents VALUES (1, 'The World of Null-A', 'Book', 55, null);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/line-item-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/line-item-init.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/line-item-init.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/line-item-init.sql Wed Apr 26 13:05:17 2006
@@ -1,16 +1,16 @@
DROP TABLE LineItems;
-CREATE TABLE LineItems
-(
- LineItem_Id int4 NOT NULL,
- Order_Id int4 NOT NULL,
- LineItem_Code varchar(32) NOT NULL,
- LineItem_Quantity int4 NOT NULL,
- LineItem_Price numeric(18,2),
- LineItem_Picture bytea,
- CONSTRAINT PK_LineItems PRIMARY KEY (LineItem_Id, Order_Id)
-)
-WITHOUT OIDS;
+CREATE TABLE LineItems
+(
+ LineItem_Id int4 NOT NULL,
+ Order_Id int4 NOT NULL,
+ LineItem_Code varchar(32) NOT NULL,
+ LineItem_Quantity int4 NOT NULL,
+ LineItem_Price numeric(18,2),
+ LineItem_Picture bytea,
+ CONSTRAINT PK_LineItems PRIMARY KEY (LineItem_Id, Order_Id)
+)
+WITHOUT OIDS;
ALTER TABLE LineItems OWNER TO "IBatisNet";
INSERT INTO LineItems VALUES (1, 10, 'ESM-34', 1, 45.43, null);
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/nullable-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/nullable-init.sql?rev=397283&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/nullable-init.sql (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/nullable-init.sql Wed Apr 26 13:05:17 2006
@@ -0,0 +1,20 @@
+
+DROP TABLE Nullable;
+
+CREATE TABLE Nullable
+(
+ Id serial NOT NULL,
+ TestBool bool,
+ TestByte int4,
+ TestChar char(1),
+ TestDateTime timestamp(0),
+ TestDecimal numeric(9,2),
+ TestDouble float8,
+ TestGuid char(16),
+ TestInt16 int2,
+ TestInt32 int4,
+ TestInt64 int8,
+ TestSingle float4,
+ CONSTRAINT PK_Nullable PRIMARY KEY (Id)
+) WITHOUT OIDS;
+ALTER TABLE Nullable OWNER TO "IBatisNet";
\ No newline at end of file
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/other-init.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/other-init.sql?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/other-init.sql (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/PostgreSQL/other-init.sql Wed Apr 26 13:05:17 2006
@@ -6,21 +6,21 @@
drop table E;
drop table F;
-CREATE TABLE Others
-(
- Other_Int int4,
- Other_Long int8,
- Other_Bit bool NOT NULL DEFAULT false,
- Other_String varchar(32) NOT NULL
-)
-WITHOUT OIDS;
+CREATE TABLE Others
+(
+ Other_Int int4,
+ Other_Long int8,
+ Other_Bit bool NOT NULL DEFAULT false,
+ Other_String varchar(32) NOT NULL
+)
+WITHOUT OIDS;
ALTER TABLE Others OWNER TO "IBatisNet";
CREATE TABLE F (
ID varchar(50) NOT NULL ,
F_Libelle varchar(50) NULL
)
-WITHOUT OIDS;
+WITHOUT OIDS;
ALTER TABLE F OWNER TO "IBatisNet";
CREATE TABLE E (
@@ -59,8 +59,8 @@
ALTER TABLE A OWNER TO "IBatisNet";
INSERT INTO Others VALUES(1, 8888888, false, 'Oui');
-INSERT INTO Others VALUES(2, 9999999999, true, 'Non');
-
+INSERT INTO Others VALUES(2, 9999999999, true, 'Non');
+
INSERT INTO F VALUES('f', 'fff');
INSERT INTO E VALUES('e', 'eee');
INSERT INTO D VALUES('d', 'ddd');
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config Wed Apr 26 13:05:17 2006
@@ -15,7 +15,7 @@
<!-- ==== PostgreSQL configuration ========= -->
<!-- Rem : If used via a DataAccess context, database tag will be ignored -->
<database>
- <provider name="PostgreSql0.98.2.0"/>
+ <provider name="PostgreSql0.99.1.0"/>
<!--
connectionString=
Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/providers.config Wed Apr 26 13:05:17 2006
@@ -19,7 +19,7 @@
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
- allowMARS="false"
+ allowMARS="false"
/>
<provider
name="sqlServer1.1"
@@ -38,7 +38,7 @@
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
- allowMARS="false"
+ allowMARS="false"
/>
<provider
name="sqlServer2.0"
@@ -270,10 +270,10 @@
allowMARS="false"
/>
<provider
- name="PostgreSql0.98.2.0"
- description="PostgreSql, Npgsql provider V0.98.2.0"
+ name="PostgreSql0.99.1.0"
+ description="PostgreSql, Npgsql provider V0.99.1.0"
enabled="false"
- assemblyName="Npgsql, Version=0.98.2.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
+ assemblyName="Npgsql, Version=0.99.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
connectionClass="Npgsql.NpgsqlConnection"
commandClass="Npgsql.NpgsqlCommand"
parameterClass="Npgsql.NpgsqlParameter"
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs?rev=397283&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs Wed Apr 26 13:05:17 2006
@@ -0,0 +1,652 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Data;
+using IBatisNet.Common;
+using IBatisNet.DataMapper.Exceptions;
+
+namespace IBatisNet.DataMapper.Commands
+{
+ /// <summary>
+ /// An implementation of <see cref="IDataReader"/> that will copy the contents
+ /// of the an open <see cref="IDataReader"/> to an in-memory <see cref="InMemoryDataReader"/> if the
+ /// session <see cref="IDbProvider"/> doesn't allow multiple open <see cref="IDataReader"/> with
+ /// the same <see cref="IDbConnection"/>.
+ /// </summary>
+ public class InMemoryDataReader : IDataReader
+ {
+ private int _currentRowIndex = 0;
+ private int _currentResultIndex = 0;
+
+ private bool _isClosed = false;
+
+ private InMemoryResultSet[ ] _results = null;
+
+
+ /// <summary>
+ /// Creates an InMemoryDataReader from a <see cref="IDataReader" />
+ /// </summary>
+ /// <param name="reader">The <see cref="IDataReader" /> which holds the records from the Database.</param>
+ public InMemoryDataReader(IDataReader reader)
+ {
+ ArrayList resultList = new ArrayList();
+
+ try
+ {
+ _currentResultIndex = 0;
+ _currentRowIndex = 0;
+
+ resultList.Add( new InMemoryResultSet( reader, true ) );
+
+ while( reader.NextResult() )
+ {
+ resultList.Add( new InMemoryResultSet( reader, false ) );
+ }
+
+ _results = ( InMemoryResultSet[ ] ) resultList.ToArray( typeof( InMemoryResultSet ) );
+ }
+ catch( Exception e )
+ {
+ throw new DataMapperException( "There was a problem converting an IDataReader to an InMemoryDataReader", e );
+ }
+ finally
+ {
+ reader.Close();
+ reader.Dispose();
+ }
+ }
+
+
+ #region IDataReader Members
+
+ /// <summary>
+ /// Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
+ /// </summary>
+ public int RecordsAffected
+ {
+ get { throw new NotImplementedException( "InMemoryDataReader only used for select IList statements !" ); }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the data reader is closed.
+ /// </summary>
+ public bool IsClosed
+ {
+ get { return _isClosed; }
+ }
+
+ /// <summary>
+ /// Advances the data reader to the next result, when reading the results of batch SQL statements.
+ /// </summary>
+ /// <returns></returns>
+ public bool NextResult()
+ {
+ _currentResultIndex++;
+ if( _currentResultIndex >= _results.Length )
+ {
+ _currentResultIndex--;
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Closes the IDataReader 0bject.
+ /// </summary>
+ public void Close()
+ {
+ _isClosed = true;
+ }
+
+ /// <summary>
+ /// Advances the IDataReader to the next record.
+ /// </summary>
+ /// <returns>true if there are more rows; otherwise, false.</returns>
+ public bool Read()
+ {
+ _currentRowIndex++;
+ if( _currentRowIndex >= _results[ _currentResultIndex ].RecordCount )
+ {
+ _currentRowIndex--;
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Gets a value indicating the depth of nesting for the current row.
+ /// </summary>
+ public int Depth
+ {
+ get { return _currentResultIndex; }
+ }
+
+ /// <summary>
+ /// Returns a DataTable that describes the column metadata of the IDataReader.
+ /// </summary>
+ /// <returns></returns>
+ public DataTable GetSchemaTable()
+ {
+ throw new NotImplementedException( "GetSchemaTable() is not implemented, cause not use." );
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ _isClosed = true;
+ _results = null;
+ }
+
+ #endregion
+
+ #region IDataRecord Members
+
+ /// <summary>
+ /// Gets the 32-bit signed integer value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public int GetInt32(int fieldIndex)
+ {
+ return (int) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the column with the specified name.
+ /// </summary>
+ public object this[string name]
+ {
+ get { return this [GetOrdinal(name)]; }
+ }
+
+ /// <summary>
+ /// Gets the column located at the specified index.
+ /// </summary>
+ public object this[int fieldIndex]
+ {
+ get { return GetValue( fieldIndex ); }
+ }
+
+ /// <summary>
+ /// Return the value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The index of the field to find. </param>
+ /// <returns>The object which will contain the field value upon return.</returns>
+ public object GetValue(int fieldIndex)
+ {
+ return this.CurrentResultSet.GetValue( _currentRowIndex, fieldIndex );
+ }
+
+ /// <summary>
+ /// Return whether the specified field is set to null.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public bool IsDBNull(int fieldIndex)
+ {
+ return (GetValue(fieldIndex) == DBNull.Value);
+ }
+
+ /// <summary>
+ /// Reads a stream of bytes from the specified column offset into the buffer as an array,
+ /// starting at the given buffer offset.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <param name="dataIndex">The index within the field from which to begin the read operation. </param>
+ /// <param name="buffer">The buffer into which to read the stream of bytes. </param>
+ /// <param name="bufferIndex">The index for buffer to begin the read operation.</param>
+ /// <param name="length">The number of bytes to read. </param>
+ /// <returns>The actual number of bytes read.</returns>
+ public long GetBytes(int fieldIndex, long dataIndex, byte[] buffer, int bufferIndex, int length)
+ {
+ object value = GetValue(fieldIndex);
+ if (!(value is byte []))
+ {
+ throw new InvalidCastException ("Type is " + value.GetType ().ToString ());
+ }
+
+ if ( buffer == null )
+ {
+ // Return length of data
+ return ((byte []) value).Length;
+ }
+ else
+ {
+ // Copy data into buffer
+ int availableLength = (int) ( ( (byte []) value).Length - dataIndex);
+ if (availableLength < length)
+ {
+ length = availableLength;
+ }
+
+ Array.Copy ((byte []) value, (int) dataIndex, buffer, bufferIndex, length);
+ return length;
+ }
+ }
+
+
+ /// <summary>
+ /// Gets the 8-bit unsigned integer value of the specified column.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public byte GetByte(int fieldIndex)
+ {
+ return (byte) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the Type information corresponding to the type of Object that would be returned from GetValue.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public Type GetFieldType(int fieldIndex)
+ {
+ return this.CurrentResultSet.GetFieldType(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the fixed-position numeric value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public decimal GetDecimal(int fieldIndex)
+ {
+ return (decimal) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets all the attribute fields in the collection for the current record.
+ /// </summary>
+ /// <param name="values"></param>
+ /// <returns></returns>
+ public int GetValues(object[] values)
+ {
+ return this.CurrentResultSet.GetValues( _currentRowIndex, values );
+ }
+
+ /// <summary>
+ /// Gets the name for the field to find.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public string GetName(int fieldIndex)
+ {
+ return this.CurrentResultSet.GetName( fieldIndex );
+ }
+
+ /// <summary>
+ /// Indicates the number of fields within the current record. This property is read-only.
+ /// </summary>
+ public int FieldCount
+ {
+ get { return this.CurrentResultSet.FieldCount; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public long GetInt64(int fieldIndex)
+ {
+ return (long) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public double GetDouble(int fieldIndex)
+ {
+ return (double) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the value of the specified column as a Boolean.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public bool GetBoolean(int fieldIndex)
+ {
+ return (bool) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Returns the GUID value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public Guid GetGuid(int fieldIndex)
+ {
+ return (Guid) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Returns the value of the specified column as a DateTime object.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public DateTime GetDateTime(int fieldIndex)
+ {
+ return (DateTime) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Returns the column ordinal, given the name of the column.
+ /// </summary>
+ /// <param name="colName">The name of the column. </param>
+ /// <returns>The value of the column.</returns>
+ public int GetOrdinal(string colName)
+ {
+ return this.CurrentResultSet.GetOrdinal(colName);
+ }
+
+ /// <summary>
+ /// Gets the database type information for the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The index of the field to find.</param>
+ /// <returns>The database type information for the specified field.</returns>
+ public string GetDataTypeName(int fieldIndex)
+ {
+ return this.CurrentResultSet.GetDataTypeName(fieldIndex);
+ }
+
+ /// <summary>
+ /// Returns the value of the specified column as a single-precision floating point number.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public float GetFloat(int fieldIndex)
+ {
+ return (float) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets an IDataReader to be used when the field points to more remote structured data.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public IDataReader GetData(int fieldIndex)
+ {
+ throw new NotImplementedException( "GetData(int) is not implemented, cause not use." );
+ }
+
+ /// <summary>
+ /// Reads a stream of characters from the specified column offset into the buffer as an array,
+ /// starting at the given buffer offset.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <param name="dataIndex">The index within the row from which to begin the read operation.</param>
+ /// <param name="buffer">The buffer into which to read the stream of bytes.</param>
+ /// <param name="bufferIndex">The index for buffer to begin the read operation. </param>
+ /// <param name="length">The number of bytes to read.</param>
+ /// <returns>The actual number of characters read.</returns>
+ public long GetChars(int fieldIndex, long dataIndex, char[] buffer, int bufferIndex, int length)
+ {
+ object value = GetValue(fieldIndex);
+ char [] valueBuffer = null;
+
+ if (value is char[])
+ {
+ valueBuffer = (char[])value;
+ }
+ else if (value is string)
+ {
+ valueBuffer = ((string)value).ToCharArray();
+ }
+ else
+ {
+ throw new InvalidCastException ("Type is " + value.GetType ().ToString ());
+ }
+
+ if ( buffer == null )
+ {
+ // Return length of data
+ return valueBuffer.Length;
+ }
+ else
+ {
+ // Copy data into buffer
+ Array.Copy (valueBuffer, (int) dataIndex, buffer, bufferIndex, length);
+ return valueBuffer.Length - dataIndex;
+ }
+
+ }
+
+ /// <summary>
+ /// Gets the string value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public string GetString(int fieldIndex)
+ {
+ return (string) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the character value of the specified column.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public char GetChar(int fieldIndex)
+ {
+ return (char) GetValue(fieldIndex);
+ }
+
+ /// <summary>
+ /// Gets the 16-bit signed integer value of the specified field.
+ /// </summary>
+ /// <param name="fieldIndex">The zero-based column ordinal. </param>
+ /// <returns>The value of the column.</returns>
+ public short GetInt16(int fieldIndex)
+ {
+ return (short)GetValue (fieldIndex);
+ }
+
+ #endregion
+
+
+ /// <summary>
+ /// Gets the current result set.
+ /// </summary>
+ /// <value>The current result set.</value>
+ private InMemoryResultSet CurrentResultSet
+ {
+ get {return _results[ _currentResultIndex ];}
+ }
+
+ /// <summary>
+ /// Represent an in-memory result set
+ /// </summary>
+ private class InMemoryResultSet
+ {
+ // [row][column]
+ private readonly object[ ][ ] _records = null;
+ private int _fieldCount = 0;
+
+ private string[] _fieldsName = null;
+ private Type[] _fieldsType = null;
+ StringDictionary _fieldsNameLookup = new StringDictionary();
+ private string[] _dataTypeName = null;
+
+ /// <summary>
+ /// Creates an in-memory ResultSet from a <see cref="IDataReader" />
+ /// </summary>
+ /// <param name="isMidstream">
+ /// <c>true</c> if the <see cref="IDataReader"/> is already positioned on the record
+ /// to start reading from.
+ /// </param>
+ /// <param name="reader">The <see cref="IDataReader" /> which holds the records from the Database.</param>
+ public InMemoryResultSet(IDataReader reader, bool isMidstream )
+ {
+ // [record index][ columns values=object[ ] ]
+ ArrayList recordsList = new ArrayList();
+
+ _fieldCount = reader.FieldCount;
+ _fieldsName = new string[_fieldCount];
+ _fieldsType = new Type[_fieldCount];
+ _dataTypeName = new string[_fieldCount];
+
+
+ bool firstRow = true;
+
+ // if we are in the middle of processing the reader then don't bother
+ // to move to the next record - just use the current one.
+ // Copy the records in memory
+ while( isMidstream || reader.Read())
+ {
+ if( firstRow )
+ {
+ for( int fieldIndex = 0; fieldIndex < reader.FieldCount; fieldIndex++ )
+ {
+ string fieldName = reader.GetName( fieldIndex );
+
+ _fieldsName[ fieldIndex ] = fieldName;
+ if (!_fieldsNameLookup.ContainsKey(fieldName))
+ {
+ _fieldsNameLookup.Add(fieldName, fieldIndex.ToString() );
+ }
+
+ _fieldsType[fieldIndex] = reader.GetFieldType( fieldIndex ) ;
+ _dataTypeName[ fieldIndex ] = reader.GetDataTypeName( fieldIndex );
+ }
+ }
+
+ firstRow = false;
+
+ object[ ] columnsValues = new object[_fieldCount];
+ reader.GetValues( columnsValues );
+ recordsList.Add( columnsValues );
+
+ isMidstream = false;
+ }
+ _records = ( object[ ][ ] ) recordsList.ToArray( typeof( object[ ] ) );
+
+ }
+
+ /// <summary>
+ /// Gets the number of columns in the current row.
+ /// </summary>
+ /// <value>The number of columns in the current row.</value>
+ public int FieldCount
+ {
+ get {return _fieldCount;}
+ }
+
+ /// <summary>
+ /// Get a column value in a row
+ /// </summary>
+ /// <param name="rowIndex">The row index</param>
+ /// <param name="colIndex">The column index</param>
+ /// <returns>The column value</returns>
+ public object GetValue( int rowIndex, int colIndex )
+ {
+ return _records[ rowIndex ][ colIndex ];
+ }
+
+ /// <summary>
+ /// The number of record contained in the ResultSet.
+ /// </summary>
+ public int RecordCount
+ {
+ get { return _records.Length; }
+ }
+
+
+ /// <summary>
+ /// Gets the type of the field.
+ /// </summary>
+ /// <param name="colIndex">Index of the col.</param>
+ /// <returns>The type of the field.</returns>
+ public Type GetFieldType( int colIndex )
+ {
+ return _fieldsType[ colIndex ];
+ }
+
+ /// <summary>
+ /// Gets the name of the field.
+ /// </summary>
+ /// <param name="colIndex">Index of the col.</param>
+ /// <returns>The name of the field.</returns>
+ public string GetName( int colIndex )
+ {
+ return _fieldsName[ colIndex ];
+ }
+
+ /// <summary>
+ /// Gets the ordinal.
+ /// </summary>
+ /// <param name="colName">Name of the column.</param>
+ /// <returns>The ordinal of the column</returns>
+ public int GetOrdinal( string colName )
+ {
+ if( _fieldsNameLookup.ContainsKey(colName) )
+ {
+ return Convert.ToInt32(_fieldsNameLookup[ colName ]);
+ }
+ else
+ {
+ throw new IndexOutOfRangeException( String.Format( "No column with the specified name was found: {0}.", colName ) );
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the database type.
+ /// </summary>
+ /// <param name="colIndex">Index of the col.</param>
+ /// <returns>The name of the database type</returns>
+ public string GetDataTypeName( int colIndex )
+ {
+ return _dataTypeName[ colIndex ];
+ }
+
+
+ /// <summary>
+ /// Gets the values.
+ /// </summary>
+ /// <param name="rowIndex">Index of the row.</param>
+ /// <param name="values">The values.</param>
+ /// <returns></returns>
+ public int GetValues( int rowIndex, object[ ] values )
+ {
+ Array.Copy( _records[ rowIndex ], 0, values, 0, _fieldCount );
+ return _fieldCount;
+ }
+ }
+
+
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderAdapter.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs?rev=397283&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs Wed Apr 26 13:05:17 2006
@@ -0,0 +1,56 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System.Data;
+using IBatisNet.Common;
+
+namespace IBatisNet.DataMapper.Commands
+{
+ /// <summary>
+ /// For <see cref="IDataReader"/> which don't support M.A.R.S, wraps the current <see cref="IDataReader"/>
+ /// in an <see cref="InMemoryDataReader"/>.
+ /// </summary>
+ public class DataReaderTransformer
+ {
+
+ /// <summary>
+ /// Creates a DataReaderAdapter from a <see cref="IDataReader" />
+ /// </summary>
+ /// <param name="reader">The <see cref="IDataReader" /> which holds the records from the Database.</param>
+ /// <param name="dbProvider">The databse provider <see cref="IDbProvider"/></param>
+ public static IDataReader Transforme(IDataReader reader, IDbProvider dbProvider)
+ {
+ if (!dbProvider.AllowMARS)
+ {
+ // The underlying reader will be closed.
+ return new InMemoryDataReader(reader);
+ }
+ else
+ {
+ return reader;
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderTransformer.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=397283&r1=397282&r2=397283&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Wed Apr 26 13:05:17 2006
@@ -288,19 +288,46 @@
private ConfigurationScope _configScope = null;
private DeSerializerFactory _deSerializerFactory = null;
private InlineParameterMapParser _paramParser = null;
+ private IObjectFactory _objectFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
+ private bool _validateSqlMapConfig = true;
#endregion
+ /// <summary>
+ /// Allow to set a custom member accessor factory, see <see cref="IMemberAccessorFactory"/>
+ /// </summary>
+ public IMemberAccessorFactory MemberAccessorFactory
+ {
+ set { _memberAccessorFactory = value; }
+ }
+
+ /// <summary>
+ /// Allow to set a custom object factory, see <see cref="IObjectFactory"/>
+ /// </summary>
+ public IObjectFactory IObjectFactory
+ {
+ set { _objectFactory = value; }
+ }
+
+ /// <summary>
+ /// Enable whether or not the validation of configuration document.
+ /// </summary>
+ public bool ValidateSqlMapConfig
+ {
+ set { _validateSqlMapConfig = value; }
+ }
+
#region Constructor
/// <summary>
- /// Default constructor
+ /// Constructs a DomSqlMapBuilder.
/// </summary>
public DomSqlMapBuilder()
{
- _configScope = new ConfigurationScope();
- _paramParser = new InlineParameterMapParser();
- _deSerializerFactory = new DeSerializerFactory(_configScope);
+ _configScope = new ConfigurationScope();
+ _paramParser = new InlineParameterMapParser();
+ _deSerializerFactory = new DeSerializerFactory(_configScope);
}
/// <summary>
@@ -312,10 +339,11 @@
/// Specify whether the configuration Xml document should be
/// validated with the SqlMapConfig schema.
/// </param>
+ [Obsolete("Use property ValidateSqlMapConfig before call Configure method.")]
public DomSqlMapBuilder(bool validateSqlMapConfig)
{
_configScope = new ConfigurationScope();
- _configScope.ValidateSqlMapConfig = validateSqlMapConfig;
+ _validateSqlMapConfig = validateSqlMapConfig;
_deSerializerFactory = new DeSerializerFactory(_configScope);
_paramParser = new InlineParameterMapParser();
}
@@ -521,7 +549,7 @@
try
{
- if (_configScope.ValidateSqlMapConfig)
+ if (_validateSqlMapConfig)
{
ValidateSchema( document.ChildNodes[1], "SqlMapConfig.xsd" );
}
@@ -695,7 +723,16 @@
#endregion
- _configScope.SqlMapper = new SqlMapper( _configScope.UseReflectionOptimizer, new TypeHandlerFactory() );
+ if (_objectFactory == null)
+ {
+ _objectFactory = new ObjectFactory(_configScope.UseReflectionOptimizer);
+ }
+ if (_memberAccessorFactory == null)
+ {
+ _memberAccessorFactory = new MemberAccessorFactory(_configScope.UseReflectionOptimizer);
+ }
+
+ _configScope.SqlMapper = new SqlMapper(_objectFactory, _memberAccessorFactory);
_configScope.SqlMapper.CacheModelsEnabled =_configScope.IsCacheModelsEnabled;
#region Cache Alias
@@ -866,7 +903,7 @@
}
#endregion
- #region Resolve "resultMap" attribute on Result Property + initialize Discriminator property
+ #region Resolve "resultMap" attribute on Result/Argument Property + initialize Discriminator property
foreach(DictionaryEntry entry in _configScope.SqlMapper.ResultMaps)
{
@@ -876,6 +913,14 @@
for(int index=0; index< resultMap.Properties.Count; index++)
{
ResultProperty result = resultMap.Properties[index];
+ if(result.NestedResultMapName.Length >0)
+ {
+ result.NestedResultMap = _configScope.SqlMapper.GetResultMap(result.NestedResultMapName);
+ }
+ }
+ for(int index=0; index< resultMap.Parameters.Count; index++)
+ {
+ ResultProperty result = resultMap.Parameters[index];
if(result.NestedResultMapName.Length >0)
{
result.NestedResultMap = _configScope.SqlMapper.GetResultMap(result.NestedResultMapName);