Author: gbayon
Date: Mon Aug 1 13:09:22 2005
New Revision: 226870
URL: http://svn.apache.org/viewcvs?rev=226870&view=rev
Log:
- Added support for 1-0 relation
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/order-init.sql
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Order.xml
Mon Aug 1 13:09:22 2005
@@ -165,10 +165,33 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
resultMap="lite-order-result-by-name" >
@@ -331,7 +354,29 @@
from Accounts
where Account_ID = #value#
</select>
-
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Order.xml
Mon Aug 1 13:09:22 2005
@@ -165,7 +165,23 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
@@ -190,13 +206,19 @@
Order_PostalCode
from Orders where Order_ID = #value#
</statement>
-
+
<statement id="GetOrderWithTypes"
parameterClass="Int"
resultMap="order-with-types-result" >
select * from Orders where Order_ID = #value#
</statement>
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderWithLineItems"
parameterClass="Integer"
resultMap="order-with-lines-result" >
@@ -331,6 +353,27 @@
where Account_ID = #value#
</select>
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
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=226870&r1=226869&r2=226870&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
Mon Aug 1 13:09:22 2005
@@ -171,6 +171,19 @@
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
</resultMaps>
<statements>
@@ -353,6 +366,27 @@
where Account_ID = #value#
</select>
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Order.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Order.xml?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Order.xml
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Order.xml
Mon Aug 1 13:09:22 2005
@@ -152,10 +152,33 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
resultMap="lite-order-result-by-name" >
@@ -311,7 +334,29 @@
from Accounts
where Account_ID = #value#
</select>
-
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Order.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Order.xml?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Order.xml
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Order.xml
Mon Aug 1 13:09:22 2005
@@ -152,10 +152,33 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
resultMap="lite-order-result-by-name" >
@@ -314,7 +337,29 @@
from Accounts
where Account_ID = #value#
</select>
-
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Order.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Order.xml?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Order.xml
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Order.xml
Mon Aug 1 13:09:22 2005
@@ -152,10 +152,33 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
resultMap="lite-order-result-by-name" >
@@ -295,7 +318,29 @@
from Accounts
where Account_ID = #value#
</select>
-
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
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=226870&r1=226869&r2=226870&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
Mon Aug 1 13:09:22 2005
@@ -152,10 +152,33 @@
<result property="PostalCode"
column="Order_PostalCode"/>
<result property="FavouriteLineItem"
resultMapping="LineItem.LineItem" />
</resultMap>
-
+
+ <resultMap id="order-joined-with-account" 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"/>
+ <result property="Account"
resultMapping="Account.account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="Hashtable">
+ <result property="Date" column="Order_Date"
nullValue="01/01/0001 00:00:00"/>
+ </resultMap>
</resultMaps>
<statements>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderLiteByColumnName"
parameterClass="Int"
resultMap="lite-order-result-by-name" >
@@ -311,7 +334,29 @@
from Accounts
where Account_ID = #value#
</select>
-
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ 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>
<parameterMaps>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
Mon Aug 1 13:09:22 2005
@@ -623,7 +623,7 @@
{
IDictionary map =
sqlMap.QueryForMap("GetAllOrderWithLineItems", null, "PostalCode");
- Assert.AreEqual(10, map.Count);
+ Assert.AreEqual(11, map.Count);
Order order = ((Order) map["T4H 9G4"]);
Assert.AreEqual(2, order.LineItemsIList.Count);
@@ -647,6 +647,24 @@
Assert.IsNull(map["Gilles"]);
}
+ /// <summary>
+ /// Test ExecuteQueryForMap : Hashtable.
+ /// </summary>
+ /// <remarks>
+ /// If the keyProperty is an integer, you must acces the map
+ /// by map[integer] and not by map["integer"]
+ /// </remarks>
+ [Test]
+ public void TestExecuteQueryForWithJoined()
+ {
+ Order order =
sqlMap.QueryForObject("GetOrderJoinWithAccount",10) as Order;
+
+ Assert.IsNotNull(order.Account);
+
+ order =
sqlMap.QueryForObject("GetOrderJoinWithAccount",11) as Order;
+
+ Assert.IsNull(order.Account);
+ }
#endregion
#region Extends statement
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/order-init.sql
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/order-init.sql?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/order-init.sql
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/order-init.sql
Mon Aug 1 13:09:22 2005
@@ -12,7 +12,7 @@
CREATE TABLE [dbo].[Orders] (
[Order_ID] [int] NOT NULL ,
- [Account_ID] [int] NOT NULL ,
+ [Account_ID] [int] NULL ,
[Order_Date] [datetime] NULL ,
[Order_CardType] [varchar] (32) NULL ,
[Order_CardNumber] [varchar] (32) NULL ,
@@ -50,4 +50,5 @@
INSERT INTO [dbo].[Orders] VALUES (8, 3, '2003-02-15 8:15:00', 'AMEX',
'777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4',1);
INSERT INTO [dbo].[Orders] VALUES (9, 2, '2003-02-15 8:15:00', 'MC',
'666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4',2);
INSERT INTO [dbo].[Orders] VALUES (10, 1, '2003-02-15 8:15:00', 'VISA',
'555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4',1);
+INSERT INTO [dbo].[Orders] VALUES (11, null, '2003-02-15 8:15:00', 'VISA',
'555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY',1);
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=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
Mon Aug 1 13:09:22 2005
@@ -1549,7 +1549,7 @@
// Load the file
defined by the attribute
XmlDocument
propertiesConfig = Resources.GetAsXmlDocument(propertyNode,
_configScope.Properties);
- foreach (XmlNode node
in propertiesConfig.SelectNodes(
ApplyDataMapperNamespacePrefix(XML_GLOBAL_PROPERTIES),
_configScope.XmlNamespaceManager))
+ foreach (XmlNode node
in propertiesConfig.SelectNodes( XML_GLOBAL_PROPERTIES,
_configScope.XmlNamespaceManager))
{
_configScope.Properties[node.Attributes[PROPERTY_ELEMENT_KEY_ATTRIB].Value] =
node.Attributes[PROPERTY_ELEMENT_VALUE_ATTRIB].Value;
_logger.Info(
string.Format("Add property \"{0}\" value
\"{1}\"",node.Attributes[PROPERTY_ELEMENT_KEY_ATTRIB].Value,node.Attributes[PROPERTY_ELEMENT_VALUE_ATTRIB].Value)
);
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Mon Aug 1 13:09:22 2005
@@ -230,8 +230,11 @@
/// <param name="reader"></param>
/// <param name="resultMap"></param>
/// <param name="resultObject"></param>
- private void FillObjectWithReaderAndResultMap(RequestScope
request,IDataReader reader, ResultMap resultMap, object resultObject)
+ private void FillObjectWithReaderAndResultMap(RequestScope
request,IDataReader reader,
+ ResultMap resultMap, object resultObject)
{
+ request.IsRowDataFound = false;
+
// For each Property in the ResultMap, set the property
in the object
foreach(DictionaryEntry entry in
resultMap.ColumnsToPropertiesMap)
{
@@ -356,6 +359,7 @@
}
object dataBaseValue =
mapping.TypeHandler.GetDataBaseValue(
((IDataParameter)command.Parameters[parameterName]).Value, result.GetType() );
+ request.IsRowDataFound =
request.IsRowDataFound || (dataBaseValue != null);
ObjectProbe.SetPropertyValue(result, mapping.PropertyName, dataBaseValue);
}
@@ -673,7 +677,6 @@
ObjectProbe.SetPropertyValue(parameterObject,
selectKeyStatement.PropertyName, generatedKey);
}
- //using (IDbCommand command =
CreatePreparedCommand(request, session, parameterObject ))
using ( IDbCommand command = _preparedCommand.Create(
request, session, this.Statement, parameterObject ) )
{
if (_statement is Insert)
@@ -886,6 +889,7 @@
}
object dataBaseValue =
mapping.GetDataBaseValue( reader );
+ request.IsRowDataFound = request.IsRowDataFound
|| (dataBaseValue != null);
if (resultMap != null)
{
@@ -903,6 +907,10 @@
obj =
mapping.NestedResultMap.CreateInstanceOfResult();
FillObjectWithReaderAndResultMap(request,
reader, mapping.NestedResultMap, obj);
+ if (request.IsRowDataFound == false)
+ {
+ obj = null;
+ }
MappedStatement.SetValueOfProperty( ref target,
mapping, obj );
}
else //'select' ResultProperty
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs?rev=226870&r1=226869&r2=226870&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs Mon Aug
1 13:09:22 2005
@@ -48,6 +48,7 @@
private ResultMap _resultMap = null;
private PreparedStatement _preparedStatement = null;
private Queue _properties = new Queue();
+ bool _rowDataFound= false;
#endregion
@@ -63,6 +64,15 @@
#endregion
#region Properties
+
+ /// <summary>
+ /// Indicate if the statement have find data
+ /// </summary>
+ public bool IsRowDataFound
+ {
+ set { _rowDataFound = value; }
+ get { return _rowDataFound; }
+ }
/// <summary>
/// Get the request's error context