Author: gbayon
Date: Sun May 18 08:52:45 2008
New Revision: 657573

URL: http://svn.apache.org/viewvc?rev=657573&view=rev
Log:
fix IBATISNET-264

Modified:
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ConstructorTest.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ParameterMapTest.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ResultMapTest.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Order.xml
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ConstructorTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ConstructorTest.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ConstructorTest.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ConstructorTest.cs
 Sun May 18 08:52:45 2008
@@ -41,7 +41,7 @@
 
         [Test]
         [Category("JIRA")]
-        [Category("JIRA-260")]
+        [Description("JIRA-260")]
         public void Extend_ResultMap_with_Constructor_should_be_used()
         {
             Account account = dataMapper.QueryForObject<Account>("JIRA260", 1);

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ParameterMapTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ParameterMapTest.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ParameterMapTest.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ParameterMapTest.cs
 Sun May 18 08:52:45 2008
@@ -270,7 +270,7 @@
 
         [Test]
         [Category("JIRA")]
-        [Category("JIRA-253")]
+        [Description("JIRA-253")]
         public void Null_byte_array_should_return_null()
         {
             Account account = NewAccount6();

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ResultMapTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ResultMapTest.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ResultMapTest.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ResultMapTest.cs
 Sun May 18 08:52:45 2008
@@ -1,9 +1,11 @@
 using System.Collections;
+using System.Collections.Generic;
 using Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures;
 using NUnit.Framework;
 
 using Apache.Ibatis.DataMapper.SqlClient.Test.Domain;
 using Apache.Ibatis.DataMapper.Session;
+using NUnit.Framework.SyntaxHelpers;
 
 namespace Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures.Mapping
 {
@@ -39,6 +41,20 @@
 
         #region Result Map test
 
+        [Test]
+        public void ResultMap_with_suffix_should_work()
+        {
+            List<Order> list = 
(List<Order>)dataMapper.QueryForList<Order>("GetOrderWithPrefix", null);
+            Assert.That(list.Count, Is.EqualTo(11));
+        }
+
+        [Test]
+        public void ResultMap_with_prefix_should_work()
+        {
+            List<Order> list = 
(List<Order>)dataMapper.QueryForList<Order>("GetOrderWithSuffix", null);
+            Assert.That(list.Count, Is.EqualTo(11));
+        }
+
         /// <summary>
         /// Test a composite Key Mapping.
         /// It must be: key1,key2,... (old syntax)

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Order.xml
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Order.xml?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Order.xml
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Order.xml
 Sun May 18 08:52:45 2008
@@ -26,6 +26,9 @@
       <result property="PostalCode" column="Order_PostalCode"/>
     </resultMap>
 
+    <resultMap id="order-result-suffix" class="Order" 
extends="base-order-result" suffix="_suffix" />
+    <resultMap id="order-result-prefix" class="Order" 
extends="base-order-result" prefix="prefix_" />
+
     <resultMap id="order-result-circular" extends="base-order-result" 
class="Order">
       <result property="Account" 
resultMapping="Account.account-constructor-circular"/>
     </resultMap>
@@ -362,6 +365,36 @@
        
        <statements>
 
+    <select id="GetOrderWithPrefix" resultMap="order-result-prefix" >
+      SELECT
+        Order_ID As prefix_Order_ID,
+        Order_Date As prefix_Order_Date,
+        Order_CardExpiry As prefix_Order_CardExpiry,
+        Order_CardType As prefix_Order_CardType,
+        Order_CardNumber As prefix_Order_CardNumber,
+        Order_Street As prefix_Order_Street,
+        Order_City As prefix_Order_City,
+        Order_Province As prefix_Order_Province,
+        Order_PostalCode As prefix_Order_PostalCode
+      FROM
+      Orders
+    </select>
+
+    <select id="GetOrderWithSuffix" resultMap="order-result-suffix" >
+      SELECT
+      Order_ID As Order_ID_suffix,
+      Order_Date As Order_Date_suffix,
+      Order_CardExpiry As Order_CardExpiry_suffix,
+      Order_CardType As Order_CardType_suffix,
+      Order_CardNumber As Order_CardNumber_suffix,
+      Order_Street As Order_Street_suffix,
+      Order_City As Order_City_suffix,
+      Order_Province As Order_Province_suffix,
+      Order_PostalCode As Order_PostalCode_suffix
+      FROM
+      Orders
+    </select>
+    
     <select id="GetOrderWithAcccount"
         resultMap="order-result-circular" >
           SELECT

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/ConfigConstants.cs
 Sun May 18 08:52:45 2008
@@ -54,6 +54,14 @@
         /// <summary>
         /// Token for attribute keyColumns.
         /// </summary>
+        public const string ATTRIBUTE_SUFFIX = "suffix";
+        /// <summary>
+        /// Token for attribute keyColumns.
+        /// </summary>
+        public const string ATTRIBUTE_PREFIX = "prefix";
+        /// <summary>
+        /// Token for attribute keyColumns.
+        /// </summary>
         public const string ATTRIBUTE_KEYS_PROPERTIES = "keys";
         /// <summary>
         /// Token for attribute scale.

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
 Sun May 18 08:52:45 2008
@@ -29,6 +29,7 @@
 using System.Collections.Generic;
 using System.Reflection;
 using Apache.Ibatis.Common.Configuration;
+using Apache.Ibatis.Common.Exceptions;
 using Apache.Ibatis.Common.Utilities.Objects;
 using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config;
 using Apache.Ibatis.DataMapper.DataExchange;
@@ -66,6 +67,8 @@
             string extends = 
config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS);
             string groupBy = 
config.GetAttributeValue(ConfigConstants.ATTRIBUTE_GROUPBY);
             string keyColumns = 
config.GetAttributeValue(ConfigConstants.ATTRIBUTE_KEYS_PROPERTIES);
+            string suffix = 
ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_SUFFIX, string.Empty);
+            string prefix = 
ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_PREFIX, string.Empty);
 
             Type type = 
dataExchangeFactory.TypeHandlerFactory.GetType(className);
             IDataExchange dataExchange = 
dataExchangeFactory.GetDataExchangeForClass(type);
@@ -123,7 +126,14 @@
 
             #endregion
 
-            ResultPropertyCollection properties = BuildResultProperties(id, 
config, type, dataExchangeFactory, waitResultPropertyResolution);
+            ResultPropertyCollection properties = BuildResultProperties(
+                id, 
+                config, 
+                type, 
+                prefix,
+                suffix,
+                dataExchangeFactory, 
+                waitResultPropertyResolution);
             Discriminator discriminator = BuildDiscriminator(config, type, 
dataExchangeFactory, waitDiscriminatorResolution);
 
             ResultMap resultMap = new ResultMap(
@@ -193,6 +203,8 @@
         /// <param name="resultMapId">The result map id.</param>
         /// <param name="resultMapConfig">The result map config.</param>
         /// <param name="resultClass">The result class.</param>
+        /// <param name="prefix">The prefix.</param>
+        /// <param name="suffix">The suffix.</param>
         /// <param name="dataExchangeFactory">The data exchange 
factory.</param>
         /// <param name="waitResultPropertyResolution">The wait result 
property resolution.</param>
         /// <returns></returns>
@@ -200,6 +212,8 @@
             string resultMapId,
             IConfiguration resultMapConfig, 
             Type resultClass,
+            string prefix,
+            string suffix,
             DataExchangeFactory dataExchangeFactory,
             WaitResultPropertyResolution waitResultPropertyResolution)
         {
@@ -211,11 +225,11 @@
                 ResultProperty mapping = null;
                 try
                 {
-                    mapping = ResultPropertyDeSerializer.Deserialize(result, 
resultClass, dataExchangeFactory);
+                    mapping = ResultPropertyDeSerializer.Deserialize(result, 
resultClass, prefix, suffix, dataExchangeFactory);
                 }
                 catch(Exception e)
                 {
-                    throw new DataMapperException("In ResultMap (" + 
resultMapId + ") can't build the result property: " + 
ConfigurationUtils.GetStringAttribute(result.Attributes, 
ConfigConstants.ATTRIBUTE_PROPERTY) + ". Cause " + e.Message, e);
+                    throw new ConfigurationException("In ResultMap (" + 
resultMapId + ") can't build the result property: " + 
ConfigurationUtils.GetStringAttribute(result.Attributes, 
ConfigConstants.ATTRIBUTE_PROPERTY) + ". Cause " + e.Message, e);
                 }
                 if (mapping.NestedResultMapName.Length > 0)
                 {

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs
 Sun May 18 08:52:45 2008
@@ -42,15 +42,19 @@
         /// </summary>
         /// <param name="config">The config.</param>
         /// <param name="resultClass">The result class.</param>
+        /// <param name="prefix">The prefix.</param>
+        /// <param name="suffix">The suffix.</param>
         /// <param name="dataExchangeFactory">The data exchange 
factory.</param>
         /// <returns></returns>
         public static ResultProperty Deserialize(
             IConfiguration config, 
-            Type resultClass, 
+            Type resultClass,
+            string prefix,
+            string suffix,
             DataExchangeFactory dataExchangeFactory)
                {
             string propertyName = 
ConfigurationUtils.GetMandatoryStringAttribute(config, 
ConfigConstants.ATTRIBUTE_PROPERTY);
-            string columnName = 
ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_COLUMN);
+            string columnName = 
prefix+ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_COLUMN)+suffix;
             int columnIndex = 
ConfigurationUtils.GetIntAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_COLUMNINDEX, ResultProperty.UNKNOWN_COLUMN_INDEX);
             string clrType = 
ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_TYPE);
             string callBackName = 
ConfigurationUtils.GetStringAttribute(config.Attributes, 
ConfigConstants.ATTRIBUTE_TYPEHANDLER);

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd?rev=657573&r1=657572&r2=657573&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd Sun May 18 
08:52:45 2008
@@ -657,6 +657,8 @@
                        <xs:attribute name="extends" type="xs:string"/>
                        <xs:attribute name="groupBy" type="xs:string"/>
                        <xs:attribute name="keys" type="xs:string"/>
+                       <xs:attribute name="prefix" type="xs:string"/>
+                       <xs:attribute name="suffix" type="xs:string"/>
                </xs:complexType>
        </xs:element>
        <xs:element name="resultMaps">


Reply via email to