Interesting, in the Java version, if there is more than one record
returned, we throw an exception. Looks like in the .NET version, you
get row #1.

Larry


On 11/16/06, Dorin Manoli <[EMAIL PROTECTED]> wrote:




Hi people, I stuck with a problem for a few hours till I figured out that it
may be a iBatis Error..



Steps to reproduce. I have a Table with data (see atach)



I have the xml maped statements

<select id="GetCompanyById" resultMap="CompaniesResultMap"
parameterClass="Hashtable">

                  select
companyId,serial,regNo,regDate,legalFormId,


vatno,originCountry,officeHr,employees,businessOverseas,


printOptions,member,mail,indica,journl,comptr,isLocked,
     replyCodeId from companies

                  <isGreaterThan property ="CompanyId" compareValue ="0">

                              where companyId = #CompanyId#

                  </isGreaterThan>

                  order by companyId

            </select>

……. ….

Then I wrote a mapped class… with a method

public Company GetCompanyById(long companyId)

            {

                  Company cp = new Company();



                  try

                  {

                        Hashtable queryParams = new Hashtable();

                        queryParams.Add("CompanyId", companyId);



                        cp =
(Company)KompassMapper.Instance().QueryForObject("GetCompanyById",queryParams);



                  }

                  catch

                  {

                        throw;

                  }



                  return cp;

            }

Unit test to invoke this metnod:

[Test]

            public void GetWrongCompanyById()

            {

                  CompaniesMap companyMap = new CompaniesMap();

                  //Company getCompany = new Company();



                  Company company=companyMap.GetCompanyById(-1);

                  Assert.AreEqual(0F,company.CompanyId);



            }

Unit test result is :

KompassDataLayer.Test.CompaniesTest.GetWrongCompanyById :

      expected: <0>

       but was: <29>



so I was expected a null value instead of first record from the table .



VS watch :  cp

      BussOverseas      0     int

      bussOverseas      0     int

      changed     false bool

      Changed     false bool

      CompanyId   29    long

      companyId   29    long

      Comptr      null  string

      comptr      null  string

      emploees    100   int

      Indica      "MSE" string

      indica      "MSE" string

      isLocked    false bool

      Journl      "60"  string

      journl      "60"  string

      legalFormId 0     int

      LegalFormId 0     int

      Locked      false bool

      mail  "D"   string

      Mail  "D"   string

      Member      "2 D" string

      member      "2 D" string

      NoEmpl      100   int

      OfficeHr    "M-Fr: 9.00-17.00"      string

      officeHr    "M-Fr: 9.00-17.00"      string

      Origin      "IE"  string

      originCountry     "IE"  string

      printOptions      "1P"  string

      Prtopt      "1P"  string

      RegDate     "2001"      string

      regDate     "2001"      string

      regNo "123456N"   string

      RegNo "123456N"   string

      ReplyCodeId 0     int

      replyCodeId 0     int

      Serial      "70950520"  string

      serial      "70950520"  string

      vatno ""    string

      VatNo ""    string






Reply via email to