It is .Net, also I changed the parameterClass to parameterClass="long" And then Invoked QueryForList and I got all records in table.. Then tested with parameterClass="Company" and result is the same..
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Larry Meadors Sent: Thursday, November 16, 2006 3:09 PM To: [email protected] Subject: Re: QueryForObject bug ? 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",queryP arams); > > > > } > > 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 > > > > > >

