Uploaded image for project: 'iBatis for .NET'
  1. iBatis for .NET
  2. IBATISNET-253

N+1 issue when using sql timestamp data type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • DataMapper 1.6.1
    • DataMapper 1.6.2
    • DataMapper
    • None
    • Visual Studio 2005
      SQL Server 2005

    Description

      Select N+1 produces unexpected results when using SQL timestamp data type. Created tables in SQL 2005 as follows:
      Parent table with Id (int), Description (varchar) and RowVersion (timestamp) fields
      Child table with Id (int), ParentId (int), Description (varchar) and RowVersion (timestamp) fields

      Added 2 records to Parent table
      Added 2 records to Child table with ParentId = 1

      Created N+1 select statement joining the 2 tables as follows:
      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
      Running the above statement via iBatis results in 2 Parent objects returned, the 2nd one having an unexpected Child

      Created a different N+1 select statement joining the 2 tables as follows:
      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
      Running the above statement via iBatis results in 2 Parent objects returned, the 2nd one having no children, as expected

      It appears that the the fact that Child_RowVersion = 0x (as when viewed in a query in SQL Management Studio) iBatis creates a Child object in error.

      Attachments

        1. iBatisTest.zip
          242 kB
          Anthony Seddon

        Activity

          People

            gilles Gilles Bayon
            anthony.seddon Anthony Seddon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: