Author: gbayon
Date: Wed Sep 21 11:22:11 2005
New Revision: 290774
URL: http://svn.apache.org/viewcvs?rev=290774&view=rev
Log:
- Fixed JIRA IBATISNET-114, added remapResults="true|false" attribut on
statement node, remapping of dynamic SQL
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/DynamicAccount.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/DynamicTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/DynamicAccount.xml
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/DynamicAccount.xml?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/DynamicAccount.xml
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/DynamicAccount.xml
Wed Sep 21 11:22:11 2005
@@ -9,6 +9,27 @@
<statements>
+ <!-- IBATISNET-114 -->
+ <statement id="DynamicSqlOnColumnSelection"
+ parameterClass="Account"
+ resultClass="Account"
+ remapResults="true">
+ SELECT
+ Account_ID as Id,
+ <dynamic>
+ <isEqual property="LastName"
compareValue="Dalton" >
+ Account_FirstName as FirstName,
+ </isEqual>
+ <isEqual property="LastName"
compareValue="Dalton" >
+ Account_LastName as LastName,
+ </isEqual>
+ </dynamic>
+
+ Account_Email as EmailAddress
+ FROM
+ Accounts
+ </statement>
+
<statement id="DynamicIsEqual"
parameterClass="string"
resultClass="Account">
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/DynamicTest.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/DynamicTest.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/DynamicTest.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/DynamicTest.cs
Wed Sep 21 11:22:11 2005
@@ -41,6 +41,31 @@
#region Dynamic tests
/// <summary>
+ /// Test Dynamic Sql On Column Selection
+ /// JIRA IBATISNET-114
+ /// </summary>
+ [Test]
+ public void TestDynamicSqlOnColumnSelection()
+ {
+ Account paramAccount = new Account();
+ Account resultAccount = new Account();
+ IList list = null;
+
+ paramAccount.LastName = "Dalton";
+ list =
sqlMap.QueryForList("DynamicSqlOnColumnSelection", paramAccount);
+ resultAccount = (Account)list[0];
+ AssertAccount1( resultAccount );
+ Assert.AreEqual(5, list.Count);
+
+ paramAccount.LastName = "Bayon";
+ list =
sqlMap.QueryForList("DynamicSqlOnColumnSelection", paramAccount);
+ resultAccount = (Account)list[0];
+ Assert.IsNull(resultAccount.FirstName);
+ Assert.IsNull(resultAccount.LastName);
+ Assert.AreEqual(5, list.Count);
+ }
+
+ /// <summary>
/// Test IsNotEmpty True
/// </summary>
[Test]
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
Wed Sep 21 11:22:11 2005
@@ -59,6 +59,7 @@
delete.ParameterMapName =
NodeUtils.GetStringAttribute(prop, "parameterMap");
delete.ResultClassName =
NodeUtils.GetStringAttribute(prop, "resultClass");
delete.ResultMapName =
NodeUtils.GetStringAttribute(prop, "resultMap");
+ delete.RemapResults =
NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
for(int i=0;i<node.ChildNodes.Count;i++)
{
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
Wed Sep 21 11:22:11 2005
@@ -58,7 +58,8 @@
insert.ParameterMapName =
NodeUtils.GetStringAttribute(prop, "parameterMap");
insert.ResultClassName =
NodeUtils.GetStringAttribute(prop, "resultClass");
insert.ResultMapName =
NodeUtils.GetStringAttribute(prop, "resultMap");
-
+ insert.RemapResults =
NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
+
for(int i=0;i<node.ChildNodes.Count;i++)
{
if (node.ChildNodes[i].LocalName=="generate")
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
Wed Sep 21 11:22:11 2005
@@ -59,6 +59,7 @@
select.ParameterMapName =
NodeUtils.GetStringAttribute(prop, "parameterMap");
select.ResultClassName =
NodeUtils.GetStringAttribute(prop, "resultClass");
select.ResultMapName =
NodeUtils.GetStringAttribute(prop, "resultMap");
+ select.RemapResults =
NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
for(int i=0;i<node.ChildNodes.Count;i++)
{
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
Wed Sep 21 11:22:11 2005
@@ -59,6 +59,7 @@
statement.ParameterMapName =
NodeUtils.GetStringAttribute(prop, "parameterMap");
statement.ResultClassName =
NodeUtils.GetStringAttribute(prop, "resultClass");
statement.ResultMapName =
NodeUtils.GetStringAttribute(prop, "resultMap");
+ statement.RemapResults =
NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
return statement;
}
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
Wed Sep 21 11:22:11 2005
@@ -57,6 +57,7 @@
update.Id = NodeUtils.GetStringAttribute(prop, "id");
update.ParameterClassName =
NodeUtils.GetStringAttribute(prop, "parameterClass");
update.ParameterMapName =
NodeUtils.GetStringAttribute(prop, "parameterMap");
+ update.RemapResults =
NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
for(int i=0;i<node.ChildNodes.Count;i++)
{
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
Wed Sep 21 11:22:11 2005
@@ -44,6 +44,16 @@
{
#region Properties
+
+ /// <summary>
+ /// Allow remapping of dynamic SQL
+ /// </summary>
+ bool RemapResults
+ {
+ get;
+ set;
+ }
+
/// <summary>
/// Identifier used to identify the statement amongst the
others.
/// </summary>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs?rev=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
Wed Sep 21 11:22:11 2005
@@ -60,6 +60,8 @@
#region Fields
[NonSerialized]
+ private bool _remapResults = false;
+ [NonSerialized]
private string _id = string.Empty;
// ResultMap
[NonSerialized]
@@ -100,6 +102,16 @@
#region Properties
/// <summary>
+ /// Allow remapping of dynamic SQL
+ /// </summary>
+ [XmlAttribute("remapResults")]
+ public bool RemapResults
+ {
+ get { return _remapResults; }
+ set { _remapResults = value; }
+ }
+
+ /// <summary>
/// Extend statement attribute
/// </summary>
[XmlAttribute("extends")]
@@ -268,7 +280,6 @@
get { return _parameterMap; }
set { _parameterMap = value; }
}
-
/// <summary>
/// The type of the statement (text or procedure)
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=290774&r1=290773&r2=290774&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Wed Sep 21 11:22:11 2005
@@ -1071,25 +1071,33 @@
private void AutoMapReader( IDataReader reader,ref object
resultObject)
{
- if (_readerAutoMapper == null)
+ if (_statement.RemapResults)
{
- lock (this)
+ ReaderAutoMapper readerAutoMapper = new
ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
+ readerAutoMapper.AutoMapReader( reader, ref
resultObject );
+ _logger.Debug("The RemapResults");
+ }
+ else
+ {
+ if (_readerAutoMapper == null)
{
- if (_readerAutoMapper == null)
+ lock (this)
{
- _readerAutoMapper = new
ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
+ if (_readerAutoMapper == null)
+ {
+ _readerAutoMapper = new
ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
+ }
}
}
+ _logger.Debug("The AutoMapReader");
+ _readerAutoMapper.AutoMapReader( reader, ref
resultObject );
}
- _readerAutoMapper.AutoMapReader( reader, ref
resultObject );
}
#endregion
private class ReaderAutoMapper
{
-
-// private IList _mappings = new ArrayList();
private ResultMap _resultMap = new ResultMap();
/// <summary>