Author: gbayon
Date: Sat Jan 5 07:06:46 2008
New Revision: 609148
URL: http://svn.apache.org/viewvc?rev=609148&view=rev
Log:
Fix IBATISNET-253
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs (with
props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs (with
props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild1.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild2.xml
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs?rev=609148&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs Sat Jan 5
07:06:46 2008
@@ -0,0 +1,35 @@
+
+
+namespace IBatisNet.DataMapper.Test.Domain
+{
+ public class Child
+ {
+ private int _id;
+ public int Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+
+ private byte[] _rowVersion;
+ public byte[] RowVersion
+ {
+ get { return _rowVersion; }
+ set { _rowVersion = value; }
+ }
+
+ private int _parentId;
+ public int ParentId
+ {
+ get { return _parentId; }
+ set { _parentId = value; }
+ }
+
+ private string _description;
+ public string Description
+ {
+ get { return _description; }
+ set { _description = value; }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Child.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs?rev=609148&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs Sat Jan
5 07:06:46 2008
@@ -0,0 +1,37 @@
+
+using System.Collections.Generic;
+
+namespace IBatisNet.DataMapper.Test.Domain
+
+{
+ public class Parent
+ {
+ private int _id;
+ public int Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+
+ private byte[] _rowVersion;
+ public byte[] RowVersion
+ {
+ get { return _rowVersion; }
+ set { _rowVersion = value; }
+ }
+
+ private string _description;
+ public string Description
+ {
+ get { return _description; }
+ set { _description = value; }
+ }
+
+ private IList<Child> _children;
+ public IList<Child> Children
+ {
+ get { return _children; }
+ set { _children = value; }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Parent.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj?rev=609148&r1=609147&r2=609148&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
Sat Jan 5 07:06:46 2008
@@ -123,6 +123,7 @@
<Compile Include="Domain\Category.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Domain\Child.cs" />
<Compile Include="Domain\Complex.cs">
<SubType>Code</SubType>
</Compile>
@@ -180,6 +181,7 @@
<Compile Include="Domain\OuiNonBoolTypeHandlerCallback.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Domain\Parent.cs" />
<Compile Include="Domain\Petshop\Category.cs" />
<Compile Include="Domain\Petshop\Item.cs" />
<Compile Include="Domain\Petshop\Product.cs" />
@@ -343,6 +345,8 @@
<Content Include="Maps\MSSQL\SqlClient\Order.xml" />
<Content Include="Maps\MSSQL\SqlClient\Other.xml" />
<Content Include="Maps\MSSQL\SqlClient\ParameterClass.xml" />
+ <Content Include="Maps\MSSQL\SqlClient\ParentChild1.xml" />
+ <Content Include="Maps\MSSQL\SqlClient\ParentChild2.xml" />
<Content Include="Maps\MSSQL\SqlClient\ResultClass.xml" />
<Content Include="Maps\MSSQL\SqlClient\Simple.xml" />
<Content Include="Maps\MySql\ByteFx\Account.xml" />
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild1.xml
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild1.xml?rev=609148&view=auto
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild1.xml
(added)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild1.xml
Sat Jan 5 07:06:46 2008
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMap namespace="ParentChild1" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+ <!--Type aliases allow you to use a shorter name for long fully qualified
class names.-->
+ <alias>
+ <typeAlias alias="Parent" type="IBatisNet.DataMapper.Test.Domain.Parent,
IBatisNet.DataMapper.Test" />
+ <typeAlias alias="Child" type="IBatisNet.DataMapper.Test.Domain.Child,
IBatisNet.DataMapper.Test" />
+ </alias>
+
+ <resultMaps>
+ <resultMap id="ParentResult" class="Parent" groupBy="Id">
+ <result property="Id" column="Parent_Id" />
+ <result property="RowVersion" column="Parent_RowVersion" />
+ <result property="Description" column="Parent_Description"/>
+ <result property="Children" resultMapping="ParentChild1.ChildResult" />
+ </resultMap>
+
+ <resultMap id="ChildResult" class="Child">
+ <result property="Id" column="Child_Id" />
+ <result property="RowVersion" column="Child_RowVersion" />
+ <result property="ParentId" column="Child_ParentId" />
+ <result property="Description" column="Child_Description"/>
+ </resultMap>
+ </resultMaps>
+
+ <statements>
+ <select id="GetAllParentsNPlus1" resultMap="ParentResult">
+ SELECT
+ parent.id parent_id,
+ parent.rowversion parent_rowversion,
+ parent.description parent_description,
+ child.id child_id,
+ child.rowversion child_rowversion,
+ child.parentid child_parentid,
+ child.description child_description
+ FROM parent
+ LEFT JOIN child
+ ON parent.id = child.parentid
+ </select>
+ </statements>
+</sqlMap>
\ No newline at end of file
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild2.xml
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild2.xml?rev=609148&view=auto
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild2.xml
(added)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ParentChild2.xml
Sat Jan 5 07:06:46 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMap namespace="ParentChild2" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+ <resultMaps>
+ <resultMap id="ParentResult" class="Parent" groupBy="Id">
+ <result property="Id" column="Parent_Id" />
+ <result property="RowVersion" column="Parent_RowVersion" />
+ <result property="Description" column="Parent_Description"/>
+ <result property="Children" resultMapping="ParentChild2.ChildResult" />
+ </resultMap>
+
+ <resultMap id="ChildResult" class="Child">
+ <result property="Id" column="Child_Id" />
+ <result property="RowVersion" column="Child_RowVersion" />
+ <result property="ParentId" column="Child_ParentId" />
+ <result property="Description" column="Child_Description"/>
+ </resultMap>
+ </resultMaps>
+
+ <statements>
+ <select id="GetAllParentsNPlus2" resultMap="ParentResult">
+ SELECT
+ parent.id parent_id,
+ parent.rowversion parent_rowversion,
+ parent.description parent_description,
+ child.id child_id,
+ NULL child_rowversion,
+ child.parentid child_parentid,
+ child.description child_description
+ FROM parent
+ LEFT JOIN child
+ ON parent.id = child.parentid
+ </select>
+ </statements>
+</sqlMap>
\ No newline at end of file
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs?rev=609148&r1=609147&r2=609148&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
Sat Jan 5 07:06:46 2008
@@ -4,7 +4,10 @@
using System.Collections.Generic;
#endif
using IBatisNet.DataMapper.Test.Domain;
+
using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
using Category=IBatisNet.DataMapper.Test.Domain.Petshop.Category;
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
@@ -65,6 +68,16 @@
Assert.AreEqual("User", application.Users[1].Roles[1].Name);
Assert.AreEqual("Admin", application.Users[1].Roles[0].Name);
+ }
+
+ [Test]
+ [Category("JIRA-253")]
+ public void Issue_When_Using_Sql_Timestamp_Data_Type()
+ {
+ IList<Parent> parents =
sqlMap.QueryForList<Parent>("GetAllParentsNPlus1", null);
+
+ Assert.That(parents[0].Children.Count, Is.EqualTo(2));
+ Assert.That(parents[1].Children.Count, Is.EqualTo(0));
}
#endif
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?rev=609148&r1=609147&r2=609148&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
Sat Jan 5 07:06:46 2008
@@ -48,13 +48,16 @@
<sqlMap resource="../../Maps/MSSQL/SqlClient/Other.xml"/>
<sqlMap
resource="../../Maps/MSSQL/SqlClient/ParameterClass.xml"/>
<sqlMap resource="../../Maps/MSSQL/SqlClient/ResultClass.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/NewsPaper.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/Document.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/NewsPaper.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/Document.xml"/>
<sqlMap
resource="../../Maps/MSSQL/SqlClient/EmbedParameter.xml"/>
<sqlMap resource="../../Maps/MSSQL/SqlClient/Nullable.xml"/>
<sqlMap resource="../../Maps/MSSQL/SqlClient/Simple.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/ConstructorInjection.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/GroupByMapping.xml"/>
- <sqlMap resource="../../Maps/MSSQL/SqlClient/Coupons.xml"/>
+ <sqlMap
resource="../../Maps/MSSQL/SqlClient/ConstructorInjection.xml"/>
+ <sqlMap
resource="../../Maps/MSSQL/SqlClient/GroupByMapping.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/Coupons.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/ParentChild1.xml"/>
+ <sqlMap resource="../../Maps/MSSQL/SqlClient/ParentChild2.xml"/>
+
</sqlMaps>
</sqlMapConfig>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs?rev=609148&r1=609147&r2=609148&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs
Sat Jan 5 07:06:46 2008
@@ -52,7 +52,10 @@
{
int index = dataReader.GetOrdinal(mapping.ColumnName);
- if (dataReader.IsDBNull(index) == true)
+ // determine the buffer size
+ int bufferLength = (int) dataReader.GetBytes(index, 0,
null, 0, 0);
+
+ if (bufferLength == 0)
{
return System.DBNull.Value;
}
@@ -70,8 +73,11 @@
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping,
IDataReader dataReader)
{
- if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
- {
+ // determine the buffer size
+ int bufferLength = (int)dataReader.GetBytes(mapping.ColumnIndex,
0, null, 0, 0);
+
+ if (bufferLength == 0)
+ {
return System.DBNull.Value;
}
else