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 2008/06/04 22:19:02 UTC

svn commit: r663367 - in /ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005: ./ Domain/ Fixtures/Mapping/ Fixtures/Mapping/MSSQL/ Maps/ bin/Debug/

Author: gbayon
Date: Wed Jun  4 13:19:01 2008
New Revision: 663367

URL: http://svn.apache.org/viewvc?rev=663367&view=rev
Log:
Improve support for dynamic sql via velocity, see IBATISNET-269

Added:
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs   (with props)
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Dynamic.Velocity.xml
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/bin/Debug/SqlMap.velocity.config
Modified:
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/DynamicTest.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/DynamicAccount.xml

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj Wed Jun  4 13:19:01 2008
@@ -50,6 +50,7 @@
     <Compile Include="Domain\SqlSourceWithInlineParameter.cs" />
     <Compile Include="Domain\SqlSourceWithParameter.cs" />
     <Compile Include="Fixtures\Mapping\CircularReferenceTest.cs" />
+    <Compile Include="Fixtures\Mapping\VelocityTest.cs" />
     <Compile Include="Fixtures\Modules\AliasModule.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Domain\A.cs" />
@@ -169,6 +170,7 @@
     <Content Include="Maps\Coupons.xml" />
     <Content Include="Maps\Document.xml" />
     <Content Include="Maps\DocumentModule.xml" />
+    <Content Include="Maps\Dynamic.Velocity.xml" />
     <Content Include="Maps\DynamicAccount.xml" />
     <Content Include="Maps\EmbedParameter.xml" />
     <Content Include="Maps\Enumeration.xml" />
@@ -218,6 +220,7 @@
     <Content Include="Scripts\ps_SelectAllAccount.sql" />
     <None Include="App.config" />
     <None Include="bin\Debug\SqlMap.config.json" />
+    <None Include="bin\Debug\SqlMap.velocity.config" />
     <None Include="DataBase.config" />
     <None Include="Scripts\ps_SelectByIdList.sql" />
     <Content Include="Scripts\ps_SelectLineItem.sql" />

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs Wed Jun  4 13:19:01 2008
@@ -1,6 +1,10 @@
+using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Reflection;
 using Apache.Ibatis.Common.Contracts;
+using Apache.Ibatis.Common.Logging;
+using Apache.Ibatis.DataMapper.Exceptions;
 using Apache.Ibatis.DataMapper.MappedStatements;
 using Apache.Ibatis.DataMapper.Model.Sql.External;
 using NVelocity;
@@ -18,6 +22,8 @@
     public class NVelocitySqlSource : ISqlSource
     {
         private readonly VelocityEngine velocityEngine = null;
+        private const string VELOCITY_DIRECTIVE = "$";
+        private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
         /// <summary>
         /// Initializes a new instance of the <see cref="NVelocitySqlSource"/> class.
@@ -46,19 +52,42 @@
 
             StringWriter sw = new StringWriter();
             ExternalSql externalSql = (ExternalSql)mappedStatement.Statement.Sql;
+            
+            string commandText = externalSql.CommandText;
 
-            VelocityContext velocityContext = new VelocityContext();
-
-            IDictionary<string, object> dico = (IDictionary<string, object>)parameterObject;
-
-            foreach(string key in dico.Keys)
+            if (logger.IsDebugEnabled)
             {
-                velocityContext.Put(key, dico[key]);
+                logger.Debug("Parse velocity string '" + commandText);
             }
 
-            bool success = velocityEngine.Evaluate(velocityContext, sw, "error", externalSql.CommandText);
+            if (commandText.Contains(VELOCITY_DIRECTIVE))
+            {
+                VelocityContext velocityContext = new VelocityContext();
+
+                IDictionary<string, object> dico = (IDictionary<string, object>)parameterObject;
+
+                foreach(string key in dico.Keys)
+                {
+                    velocityContext.Put(key, dico[key]);
+                }
+
+                try
+                {
+                    velocityEngine.Evaluate(velocityContext, sw, "error", commandText);
+                }
+                catch (Exception ex)
+                {
+                    if (logger.IsDebugEnabled)
+                    {
+                        logger.Debug("Could not parse velocity string '" + commandText + "' for " + mappedStatement.Id);
+                    }
+
+                    throw new DataMapperException("Could not parse velocity string '" + commandText + "' for " + mappedStatement.Id);
+                }
+                commandText = sw.GetStringBuilder().ToString();
+            }
 
-            return sw.GetStringBuilder().ToString();
+            return commandText;
         }
 
         #endregion

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/DynamicTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/DynamicTest.cs?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/DynamicTest.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/DynamicTest.cs Wed Jun  4 13:19:01 2008
@@ -41,47 +41,6 @@
 
         #region Dynamic tests
 
-        [Test]
-        public void Nvelocity_simple_sql_template_should_work()
-        {
-            Account paramAccount = new Account();
-            paramAccount.Id = 1;
-
-            IDictionary<string, object> parameters = new Dictionary<string, object>();
-            parameters.Add("account", paramAccount);
-
-            Account account = dataMapper.QueryForObject<Account>("NVelocity.Simple", parameters);
-            Assert.That(account, Is.Not.Null);
-            AssertAccount1(account);
-        }
-
-        [Test]
-        public void Nvelocity_template_with_if_should_work()
-        {
-            Account paramAccount = new Account();
-            paramAccount.FirstName = "Joe";
-            paramAccount.Id = 1;
-
-            IDictionary<string, object> parameters = new Dictionary<string, object>();
-            parameters.Add("account", paramAccount);
-
-            Account account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
-            Assert.That(account.FirstName, Is.EqualTo("Joe"));
-            Assert.That(account.LastName, Is.Null);
-
-            paramAccount = new Account();
-            paramAccount.LastName = "Dalton";
-            paramAccount.Id = 1;
-
-            parameters = new Dictionary<string, object>();
-            parameters.Add("account", paramAccount);
-
-            account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
-            Assert.That(account.LastName, Is.EqualTo("Dalton"));
-            Assert.That(account.FirstName, Is.Null);
-
-        }
-
         /// <summary>
         /// Test Dynamic Sql On Column Selection
         /// JIRA IBATISNET-114

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs Wed Jun  4 13:19:01 2008
@@ -138,7 +138,6 @@
             account.NullBannerOption = null;
 
             dataMapper.Insert("InsertAccountViaSPWithDynamicParameter", account);
-
         }
 
         /// <summary>

Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs?rev=663367&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs Wed Jun  4 13:19:01 2008
@@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using Apache.Ibatis.Common.Data;
+using Apache.Ibatis.Common.Resources;
+using Apache.Ibatis.Common.Utilities;
+using Apache.Ibatis.DataMapper.Configuration;
+using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config.Xml;
+using Apache.Ibatis.DataMapper.Session;
+using Apache.Ibatis.DataMapper.SqlClient.Test.Domain;
+using Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures.Modules;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures.Mapping
+{
+    [TestFixture]
+    public class VelocityTest
+    {
+        private IDataMapper dataMapper = null;
+        protected static ISessionFactory sessionFactory = null;
+
+        [TestFixtureSetUp]
+        public void SetUpFixture()
+        {
+            string uri = "file://~/SqlMap.velocity.config";
+            IResource resource = ResourceLoaderRegistry.GetResource(uri);
+
+            ConfigurationSetting setting = new ConfigurationSetting();
+
+            IConfigurationEngine engine = new DefaultConfigurationEngine(setting);
+            engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));
+            engine.RegisterModule(new AliasModule());
+
+            IMapperFactory mapperFactory = engine.BuildMapperFactory();
+            sessionFactory = engine.ModelStore.SessionFactory;
+            dataMapper = ((IDataMapperAccessor)mapperFactory).DataMapper;
+        }
+
+         /// <summary>
+        /// SetUp
+        /// </summary>
+        [SetUp]
+        public void SetUp()
+        {
+            string scriptDirectory = Path.Combine(Path.Combine(Path.Combine(Resources.ApplicationBase, ".."), ".."), "Scripts") + Path.DirectorySeparatorChar;
+
+            InitScript(sessionFactory.DataSource, scriptDirectory + "account-init.sql");
+            InitScript(sessionFactory.DataSource, scriptDirectory + "ps_InsertAccountWithDefault.sql");
+        }
+
+        [Test]
+        public void Nvelocity_simple_sql_template_should_work()
+        {
+            Account paramAccount = new Account();
+            paramAccount.Id = 1;
+
+            IDictionary<string, object> parameters = new Dictionary<string, object>();
+            parameters.Add("account", paramAccount);
+
+            Account account = dataMapper.QueryForObject<Account>("NVelocity.Simple", parameters);
+            Assert.That(account, Is.Not.Null);
+            AssertAccount1(account);
+        }
+
+        [Test]
+        public void Nvelocity_template_with_if_should_work()
+        {
+            Account paramAccount = new Account();
+            paramAccount.FirstName = "Joe";
+            paramAccount.Id = 1;
+
+            IDictionary<string, object> parameters = new Dictionary<string, object>();
+            parameters.Add("account", paramAccount);
+
+            Account account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
+            Assert.That(account.FirstName, Is.EqualTo("Joe"));
+            Assert.That(account.LastName, Is.Null);
+
+            paramAccount = new Account();
+            paramAccount.LastName = "Dalton";
+            paramAccount.Id = 1;
+
+            parameters = new Dictionary<string, object>();
+            parameters.Add("account", paramAccount);
+
+            account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
+            Assert.That(account.LastName, Is.EqualTo("Dalton"));
+            Assert.That(account.FirstName, Is.Null);
+
+        }
+
+        [Test]
+        public void Nvelocity_inline_parameter_should_work()
+        {
+            IDictionary<string, object> parameters = new Dictionary<string, object>();
+            parameters.Add("LastName", "Dalton");
+
+            IList<Account> accounts = dataMapper.QueryForList<Account>("NVelocity.InlineParameter", parameters);
+            Assert.That(accounts.Count, Is.EqualTo(4));
+
+            parameters = new Dictionary<string, object>();
+            parameters.Add("LastName", "xxx");
+
+            accounts = dataMapper.QueryForList<Account>("NVelocity.InlineParameter", parameters);
+            Assert.That(accounts.Count, Is.EqualTo(5));
+        }
+
+        [Test]
+        public void Nvelocity_Iterate_should_work()
+        {
+            List<int> integers = new List<int>();
+            integers.Add(1);
+            integers.Add(2);
+            integers.Add(3);
+
+            IDictionary<string, object> parameters = new Dictionary<string, object>();
+            parameters.Add("integers", integers);
+
+            IList<Account> accounts = dataMapper.QueryForList<Account>("NVelocity.For", parameters);
+            Assert.That(accounts.Count, Is.EqualTo(3));
+            AssertAccount1(accounts[0]);
+        }
+
+        [Test]
+        public void Nvelocity_procedure_with_dynamic_parameter_should_work()
+        {
+            Account account = new Account();
+
+            account.Id = 99;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.NullBannerOption = false;
+
+            IDictionary<string, object> parameters = new Dictionary<string, object>();
+            parameters.Add("account", account);
+
+            dataMapper.Insert("NVelocity.Procedure", parameters);
+
+            Account testAccount = dataMapper.QueryForObject<Account>("NVelocity.Simple", parameters);
+
+            Assert.IsNotNull(testAccount);
+            Assert.That(testAccount.Id, Is.EqualTo(99));
+            Assert.That(testAccount.EmailAddress, Is.EqualTo("no_email@provided.com"));
+            Assert.That(testAccount.BannerOption, Is.False);
+            Assert.That(testAccount.CartOption, Is.False);
+
+            account.Id = 100;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.NullBannerOption = true;
+            account.CartOption = true;
+
+            parameters = new Dictionary<string, object>();
+            parameters.Add("account", account);
+
+            dataMapper.Insert("NVelocity.Procedure", parameters);
+
+            testAccount = dataMapper.QueryForObject<Account>("NVelocity.Simple", parameters);
+
+            Assert.IsNotNull(testAccount);
+            Assert.That(testAccount.Id, Is.EqualTo(100));
+            Assert.That(testAccount.EmailAddress, Is.EqualTo("no_email@provided.com"));
+            Assert.That(testAccount.BannerOption, Is.True);
+            Assert.That(testAccount.CartOption, Is.True);
+        }
+
+        /// <summary>
+        /// Verify that the input account is equal to the account(id=1).
+        /// </summary>
+        /// <param name="account">An account object</param>
+        private void AssertAccount1(Account account)
+        {
+            Assert.AreEqual(1, account.Id, "account.Id");
+            Assert.AreEqual("Joe", account.FirstName, "account.FirstName");
+            Assert.AreEqual("Dalton", account.LastName, "account.LastName");
+            Assert.AreEqual("Joe.Dalton@somewhere.com", account.EmailAddress, "account.EmailAddress");
+        }
+
+        /// <summary>
+        /// Run a sql batch for the datasource.
+        /// </summary>
+        /// <param name="datasource">The datasource.</param>
+        /// <param name="script">The sql batch</param>
+        public static void InitScript(IDataSource datasource, string script)
+        {
+            InitScript(datasource, script, true);
+        }
+
+        /// <summary>
+        /// Run a sql batch for the datasource.
+        /// </summary>
+        /// <param name="datasource">The datasource.</param>
+        /// <param name="script">The sql batch</param>
+        /// <param name="doParse">parse out the statements in the sql script file.</param>
+        private static void InitScript(IDataSource datasource, string script, bool doParse)
+        {
+            ScriptRunner runner = new ScriptRunner();
+
+            runner.RunScript(datasource, script, doParse);
+        }
+
+    }
+}

Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml Wed Jun  4 13:19:01 2008
@@ -811,7 +811,7 @@
       ps_SelectAccountWithOutPutParam @{Account_ID,column=Account_ID}, @{OutPut,column=OutPut}
     </procedure>
 
-    <procedure id="InsertAccountViaSPAndInlineParameter" parameterClass="map" >
+    <procedure id="InsertAccountViaSPAndInlineParameter" parameterClass="Account" >
       ps_InsertAccount
       @{Id,column=Account_ID},
       @{FirstName,column=Account_FirstName},
@@ -821,7 +821,7 @@
       @{CartOption,column=Account_Cart_Option,handler=HundredsBool}
     </procedure>
 
-    <procedure id="InsertAccountViaSPWithDefaultParameter" parameterClass="map" >
+    <procedure id="InsertAccountViaSPWithDefaultParameter" parameterClass="Account" >
       ps_InsertAccountWithDefault
       @{Id,column=Account_ID},
       @{FirstName,column=Account_FirstName},
@@ -829,7 +829,7 @@
       @{EmailAddress,column=Account_Email,nullValue=no_email@provided.com}
     </procedure>
 
-    <procedure id="InsertAccountViaSPWithDynamicParameter" parameterClass="map" >
+    <procedure id="InsertAccountViaSPWithDynamicParameter" parameterClass="Account" >
       ps_InsertAccountWithDefault
       @{Id,column=Account_ID}
       ,@{FirstName,column=Account_FirstName}

Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Dynamic.Velocity.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Dynamic.Velocity.xml?rev=663367&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Dynamic.Velocity.xml (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Dynamic.Velocity.xml Wed Jun  4 13:19:01 2008
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMap namespace="Account"
+xmlns="http://ibatis.apache.org/mapping"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+  <alias>
+    <typeAlias alias="HundredsBool" type="Apache.Ibatis.DataMapper.SqlClient.Test.Domain.HundredsTypeHandlerCallback, Apache.Ibatis.DataMapper.SqlClient.Test"/>
+  </alias>
+  
+  <resultMaps>
+
+    <resultMap id="account-result"  class="Account" >
+      <result property="id"           column="Account_ID"/>
+      <result property="FirstName"    column="Account_FirstName"/>
+      <result property="LastName"     column="Account_LastName"/>
+      <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+      <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
+      <result property="CartOption"	column="Account_Cart_Option" typeHandler="HundredsBool"/>
+    </resultMap>
+    
+  </resultMaps>
+  
+  <statements>
+
+    <select id="NVelocity.Simple" sqlSource="NVelocitySqlSource" resultMap="account-result" parameterClass="map">
+      select * from Accounts where Account_Id= $account.id
+    </select>
+
+    <select id="NVelocity.If" sqlSource="NVelocitySqlSource" resultClass="Account" remapResults="true" parameterClass="map">
+      SELECT
+      Account_ID as Id,
+
+      #if($account.FirstName == "Joe")
+      Account_FirstName as FirstName,
+      #elseif($account.LastName == "Dalton")
+      Account_LastName as LastName,
+      #end
+
+      Account_Email as EmailAddress
+      FROM
+      Accounts
+      where Account_Id= $account.id
+    </select>
+
+    <select id="NVelocity.InlineParameter" sqlSource="NVelocitySqlSource" resultClass="Account">
+      select
+      Account_ID			as Id,
+      Account_FirstName	as FirstName,
+      Account_LastName	as LastName,
+      Account_Email		as EmailAddress
+      from Accounts
+      #if($LastName == "Dalton")
+      where Account_LastName = @{LastName,column=Account_LastName}
+      #end
+    </select>
+
+    <select id="NVelocity.For" sqlSource="NVelocitySqlSource" parameterClass="list" resultClass="Account">
+      <![CDATA[ 
+      select
+      Account_ID			as Id,
+      Account_FirstName	as FirstName,
+      Account_LastName	as LastName,
+      Account_Email		as EmailAddress
+      from Accounts
+      WHERE Account_ID IN 
+      (
+        #foreach($i in $integers)
+          $i
+          #if($velocityCount < $integers.count) , #end
+        #end
+      )
+      ]]>
+    </select>
+
+
+    <procedure id="NVelocity.Procedure" sqlSource="NVelocitySqlSource" parameterClass="map">
+      ps_InsertAccountWithDefault
+      @{account.Id,column=Account_ID}
+      ,@{account.FirstName,column=Account_FirstName}
+      ,@{account.LastName,column=Account_LastName}
+      ,@{account.EmailAddress,column=Account_Email,nullValue=no_email@provided.com}
+      #if( $account.NullBannerOption  )
+      ,@{account.NullBannerOption,column=Account_Banner_Option,dbType=Varchar,type=bool}
+      #end
+      ,@{account.CartOption,column=Account_Cart_Option,handler=HundredsBool}
+    </procedure >
+    
+  </statements >
+  
+</sqlMap >

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/DynamicAccount.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/DynamicAccount.xml?rev=663367&r1=663366&r2=663367&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/DynamicAccount.xml (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/DynamicAccount.xml Wed Jun  4 13:19:01 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<sqlMap namespace="Account" 
-xmlns="http://ibatis.apache.org/mapping" 
+<sqlMap namespace="Account"
+xmlns="http://ibatis.apache.org/mapping"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
   <alias>
@@ -10,27 +10,6 @@
 
   <statements>
 
-    <!-- Nvelocity dynamic source -->
-    <select id="NVelocity.Simple" sqlSource="NVelocitySqlSource" resultMap="account-result" parameterClass="map">
-      select * from Accounts where Account_Id= $account.id
-    </select>
-
-    <select id="NVelocity.If" sqlSource="NVelocitySqlSource" resultClass="Account" remapResults="true" parameterClass="map">
-      SELECT
-      Account_ID as Id,
-
-      #if($account.FirstName == "Joe")
-      Account_FirstName as FirstName,
-      #elseif($account.LastName == "Dalton")
-      Account_LastName as LastName,
-      #end
-
-      Account_Email as EmailAddress
-      FROM
-      Accounts
-      where Account_Id= $account.id
-    </select>
-    
     <sql id="includeComplex">
       <dynamic prepend="where">
         <isParameterPresent>
@@ -59,7 +38,7 @@
       <include refid="includeComplex"/>
       order by Account_ID
     </select>
-    
+
     <statement id="DynamicJIRA168"
 					parameterClass="Query"
 					resultClass="Account">
@@ -86,14 +65,14 @@
     </statement>
 
     <!-- Apache.Ibatis-114: remapResults -->
-    <statement  id="DynamicSqlOnColumnSelection" 
-					parameterClass="Account" 
+    <statement  id="DynamicSqlOnColumnSelection"
+					parameterClass="Account"
 					resultClass="Account"
 					remapResults="true">
       SELECT
       Account_ID as Id,
       <dynamic>
-        <isEqual property="FirstName" compareValue="Dalton" >
+        <isEqual property="LastName" compareValue="Dalton" >
           Account_FirstName as FirstName,
         </isEqual>
         <isEqual property="LastName" compareValue="Dalton" >
@@ -479,9 +458,9 @@
       </dynamic>
     </statement>
 
-    <statement id="ComplexDynamicStatement" 
-			cacheModel="account-cache" 
-			resultClass="Account" 
+    <statement id="ComplexDynamicStatement"
+			cacheModel="account-cache"
+			resultClass="Account"
 			parameterClass="Account">
       select
       Account_ID			as Id,
@@ -507,8 +486,8 @@
       order by Account_LastName
     </statement>
 
-    <statement id="Jira-IBATISNET-11" 
-			resultClass="Account" 
+    <statement id="Jira-IBATISNET-11"
+			resultClass="Account"
 			parameterClass="Search">
       select
       Account_ID			as Id,

Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/bin/Debug/SqlMap.velocity.config
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/bin/Debug/SqlMap.velocity.config?rev=663367&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/bin/Debug/SqlMap.velocity.config (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/bin/Debug/SqlMap.velocity.config Wed Jun  4 13:19:01 2008
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+  <!-- Rem : If used via a DataAccess context, properties tag will be ignored -->
+  <properties uri="file://../../database.config"/>
+
+  <!-- <properties embedded="database.config, IBatisNet.Test"/> -->
+  <settings>
+    <setting useStatementNamespaces="${useStatementNamespaces}"/>
+    <setting cacheModelsEnabled="true"/>
+    <setting validateSqlMap="false"/>
+    <setting useReflectionOptimizer="true"/>
+  </settings>
+
+  <!-- Optional if resource -->
+  <providers uri="file://providers.config"/>
+
+  <!-- ==== SqlClient configuration =========	-->
+  <!-- Rem : If used via a DataAccess context, database tag will be ignored -->
+  <database>
+    <!-- Optional ( default ) -->
+    <provider name="sqlServer2.0"/>
+    <dataSource name="iBatisNet" connectionString="data source=${datasource};database=${database};Integrated Security=SSPI;"/>
+  </database>
+
+  <alias>
+    <typeAlias alias="Account" type="Apache.Ibatis.DataMapper.SqlClient.Test.Domain.Account, Apache.Ibatis.DataMapper.SqlClient.Test"/>
+    <typeAlias alias="OuiNonBool" type="Apache.Ibatis.DataMapper.SqlClient.Test.Domain.OuiNonBoolTypeHandlerCallback, Apache.Ibatis.DataMapper.SqlClient.Test"/>
+  </alias>
+
+  <typeHandlers>
+    <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
+    <typeHandler type="string" callback="AnsiStringTypeHandler"/>
+  </typeHandlers>
+  
+  <sqlMaps>
+    <sqlMap uri="file://../../Maps/Dynamic.Velocity.xml"/>
+  </sqlMaps>
+</sqlMapConfig>