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

Update Test for Access/OleDb

    XMLWordPrintableJSON

Details

    • Test
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • Testing
    • None

    Description

      The test for Access/OleDb is outdated

      Changes to update:

      === Maps/Access/Oledb/ResultClass.xml ==

      • Ln 51
        <!--
        System.InvalidCastException
        No cast function in Access SQL syntax
        select CONVERT(UNIQUEIDENTIFIER,
        'CD5ABF17-4BBC-4C86-92F1-257735414CF4') from Orders where Order_ID = #value#
        -->
        <statement id="GetGuid"
        parameterClass="Int"
        resultClass="guid" >
        select {CD5ABF17-4BBC-4C86-92F1-257735414CF4}

        from Orders where Order_ID = #value# </statement>

      ==== Maps/Access/OleDb/Documen.xml ====

      • Add this alias:
        <typeAlias alias="CustomInheritance"
        type="IBatisNet.DataMapper.Test.Domain.CustomInheritance,
        IBatisNet.DataMapper.Test"/>
      • Add to map document in discriminator property type attribute

      <resultMap id="document" class="Document">
      <result property="Id" column="Document_ID"/>
      <result property="Title" column="Document_Title"/>

      <!-- Missing the type attribute and dont work ?¿ why -->
      <discriminator column="Document_Type" type="string" />

      <subMap value="Book" resultMapping="book" />
      <subMap value="Newspaper" resultMapping="newspaper" />
      </resultMap>

      • Replace the original document-custom-formula with this

      <resultMap id="document-custom-handler" class="Document">
      <result property="Id" column="Document_ID"/>
      <result property="Title" column="Document_Title"/>
      <discriminator column="Document_Type" typeHandler="CustomInheritance"/>
      <subMap value="Book" resultMapping="book" />
      <subMap value="Newspaper" resultMapping="newspaper" />
      </resultMap>

      • Add this missing statement
        <select id="GetAllDocumentWithCustomTypeHandler"
        resultMap="document-custom-handler">
        select
        *
        from Documents
        order by Document_Type, Document_Id
        </select>

      === Maps/Access/OleDb/Account.xml ===

      • Add on line 110:

      <select id="GetNoAccountWithCache"
      parameterClass="Integer"
      resultMap="account-hashtable-result"
      cacheModel="account-cache">
      select *
      from Accounts
      where Account_ID = #value#
      </select>

      • Add on line 236

      <select id="GetAccountJIRA45"
      parameterClass="int"
      resultMap="Account.indexed-account-result">
      select
      Account_ID,
      Account_FirstName,
      Account_LastName,
      Account_Email
      from Accounts
      where Account_ID = #value#
      </select>

      • Add on line 422:

      <select id="SelectAccountJIRA29" parameterClass="map" resultClass="Account">
      select
      Account_ID as Id,
      Account_FirstName as FirstName,
      Account_LastName as LastName,
      Account_Email as EmailAddress
      from Accounts
      where Account_FirstName = '##$AccountName$##'
      </select>

      <select id="SelectAccountJIRA29-2"
      parameterClass="Hashtable"
      resultClass="Account">
      select
      Account_ID as Id,
      Account_FirstName as FirstName,
      Account_LastName as LastName,
      Account_Email as EmailAddress
      from Accounts
      where 1=1
      <isNotEmpty prepend="AND" property="Foo">
      (Account_FirstName = '##$Foo$##')
      </isNotEmpty>
      </select>

      • Add at line 468

      <select id="GetAllAccountsViaCustomTypeHandler"
      resultMap="account-result">
      select * from Accounts
      order by Account_ID
      </select>

      === Maps/Access/OleDb/Order.xml ===

      Add at line 156

      <resultMap id="order-joined-with-account" class="Order">
      <result property="Id" column="Order_ID"/>
      <result property="Date" column="Order_Date"
      nullValue="01/01/0001 00:00:00"/>
      <result property="CardExpiry" column="Order_CardExpiry"/>
      <result property="CardType" column="Order_CardType"/>
      <result property="CardNumber" column="Order_CardNumber"/>
      <result property="Street" column="Order_Street"/>
      <result property="City" column="Order_City"/>
      <result property="Province" column="Order_Province"/>
      <result property="PostalCode" column="Order_PostalCode"/>
      <result property="Account" resultMapping="Account.account-result-nullable-email"
      />
      </resultMap>

      <resultMap id="order-hash" class="Hashtable">
      <result property="Date" column="Order_Date"
      nullValue="01/01/0001 00:00:00"/>
      </resultMap>

      Add at line 205

      <statement id="GetOrderByHashTable"
      parameterClass="Integer"
      resultMap="order-hash" >
      select Order_Date from Orders where Order_ID = #value#
      </statement>

      Add at line 315

      <select id="SelectOrderByDate"
      parameterClass="Hashtable"
      resultMap="lite-order-result-by-name">
      select * from Orders where Order_Date = #Foo#
      </select>

      <select id="SelectOrderByDateDynamic"
      parameterClass="Hashtable"
      resultMap="lite-order-result-by-name">
      select * from Orders
      where 1=1
      <isNotEmpty prepend="AND" property="Foo">
      (Order_Date = '$Foo$')
      </isNotEmpty>
      </select>

      <select id="GetOrderJoinWithAccount"
      parameterClass="Integer"
      resultMap="order-joined-with-account">
      select
      Order_ID,
      Order_Date,
      Order_CardExpiry,
      Order_CardType,
      Order_CardNumber,
      Order_Street,
      Order_City,
      Order_Province,
      Order_PostalCode,
      acc.Account_ID,
      acc.Account_FirstName,
      acc.Account_LastName,
      acc.Account_Email
      from Orders as ord
      LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
      where Order_ID = #value#
      </select>

      === Maps/Access/OleDb/Other.xml ===
      Replace all for the content for Maps/MSSQL/SqlClient/Other.xml

      ===Scripts/Access/Other-init.sql ===

      drop table OTHERS;

      create table OTHERS
      (
      OTHER_INT long,
      OTHER_LONG decimal,
      OTHER_BIT YESNO,
      OTHER_STRING text(32)
      );

      INSERT INTO Others VALUES(1, 8888888, false, 'Oui');
      INSERT INTO Others VALUES(2, 9999999999,true, 'Non');

      Also move GetAccountJIRA45 in MSSQL/OleDb/Order.xml at 344 to account.xml <select id="GetAccountJIRA45"
      parameterClass="int"
      resultMap="Account.indexed-account-result">
      select
      Account_ID,
      Account_FirstName,
      Account_LastName,
      Account_Email
      from Accounts
      where Account_ID = #value#
      </select>

      Attachments

        1. AccessTestMap.zip
          5 kB
          David Marzo

        Activity

          People

            ron liu ron
            d.marzo David Marzo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: