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

Support for circular reference

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • DataMapper 3.0
    • DataMapper 3.0
    • DataMapper
    • None

    Description

      To avoid creation of new Instance of the same object during an ibatis request, add the 'keys' attribute on resultMap tag to specify the properties identifiers

      public class Order
      {
      public Account

      {get;set}

      ...
      }

      <resultMap id="account-constructor-circular" keys="identifiant" class="Account" >
      <constructor>
      <argument argumentName="identifiant" column="Account_ID"/>
      <argument argumentName="firstName" column="Account_FirstName"/>
      <argument argumentName="lastName" column="Account_LastName"/>
      </constructor>
      </resultMap>

      <resultMap id="order-result-circular" extends="base-order-result" class="Order">
      <result property="Account" resultMapping="Account.account-constructor-circular"/>
      </resultMap>

      <select id="GetOrderWithAcccount" resultMap="order-result-circular" >
      SELECT
      *
      FROM
      Orders o
      JOIN
      Accounts a
      ON
      o.Account_Id = A.Account_Id
      </select>

      List<Order> list = (List<Order>)dataMapper.QueryForList<Order>("GetOrderWithAcccount", null);

      Account account1 = list.Find(delegate(Order order)

      { return order.Id==1; }

      ).Account;
      Account account2 = list.Find(delegate(Order order)

      { return order.Id == 10; }

      ).Account;

      Assert.That(account1, Is.SameAs(account2));

      Attachments

        Activity

          People

            gilles Gilles Bayon
            gilles Gilles Bayon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: