Return-Path: Delivered-To: apmail-ibatis-user-cs-archive@www.apache.org Received: (qmail 27424 invoked from network); 16 Nov 2006 15:02:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2006 15:02:11 -0000 Received: (qmail 20396 invoked by uid 500); 16 Nov 2006 15:02:20 -0000 Delivered-To: apmail-ibatis-user-cs-archive@ibatis.apache.org Received: (qmail 20386 invoked by uid 500); 16 Nov 2006 15:02:20 -0000 Mailing-List: contact user-cs-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-cs@ibatis.apache.org Delivered-To: mailing list user-cs@ibatis.apache.org Received: (qmail 20375 invoked by uid 99); 16 Nov 2006 15:02:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2006 07:02:20 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.141.65.135] (HELO dataireland.ie) (83.141.65.135) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2006 07:02:06 -0800 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C7098F.AFC1BC52" Subject: QueryForObject bug ? X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Thu, 16 Nov 2006 14:58:33 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: QueryForObject bug ? thread-index: AccJkGWbhdLQNrLbQrSyie4o37qT+Q== From: "Dorin Manoli" To: X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C7098F.AFC1BC52 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Hi people, I stuck with a problem for a few hours till I figured out = that it may be a iBatis Error.. =20 Steps to reproduce. I have a Table with data (see atach) =20 I have the xml maped statements ....... .... Then I wrote a mapped class... with a method public Company GetCompanyById(long companyId) =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = {=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A Company cp =3D new = Company(); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A try =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A { =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = Hashtable queryParams =3D new Hashtable(); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = queryParams.Add("CompanyId", companyId); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A cp = =3D = (Company)KompassMapper.Instance().QueryForObject("GetCompanyById",queryPa= rams); =20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A } =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A catch =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A { =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = throw; =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A } =20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A return cp; =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A } Unit test to invoke this metnod: [Test] =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A public void GetWrongCompanyById() =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A { =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A CompaniesMap = companyMap =3D new CompaniesMap(); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A //Company getCompany = =3D new Company(); =20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A Company = company=3DcompanyMap.GetCompanyById(-1); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = Assert.AreEqual(0F,company.CompanyId); =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=20 =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A } Unit test result is :=20 KompassDataLayer.Test.CompaniesTest.GetWrongCompanyById :=20 =9A=9A=9A=9A=9A expected: <0> =9A=9A=9A=9A=9A =9Abut was: <29> =20 so I was expected a null value instead of first record from the table . =20 VS watch :=9A cp =9A=9A=9A=9A=9A BussOverseas=9A=9A=9A=9A=9A 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A bussOverseas=9A=9A=9A=9A=9A 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A changed=9A=9A=9A=9A false bool =9A=9A=9A=9A=9A Changed=9A=9A=9A=9A false bool =9A=9A=9A=9A=9A CompanyId=9A=9A 29=9A=9A=9A long =9A=9A=9A=9A=9A companyId=9A=9A 29=9A=9A=9A long =9A=9A=9A=9A=9A Comptr=9A=9A=9A=9A=9A null=9A string =9A=9A=9A=9A=9A comptr=9A=9A=9A=9A=9A null=9A string =9A=9A=9A=9A=9A emploees=9A=9A=9A 100=9A=9A int =9A=9A=9A=9A=9A Indica=9A=9A=9A=9A=9A "MSE" string =9A=9A=9A=9A=9A indica=9A=9A=9A=9A=9A "MSE" string =9A=9A=9A=9A=9A isLocked=9A=9A=9A false bool =9A=9A=9A=9A=9A Journl=9A=9A=9A=9A=9A "60"=9A string =9A=9A=9A=9A=9A journl=9A=9A=9A=9A=9A "60"=9A string =9A=9A=9A=9A=9A legalFormId 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A LegalFormId 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A Locked=9A=9A=9A=9A=9A false bool =9A=9A=9A=9A=9A mail=9A "D"=9A=9A string =9A=9A=9A=9A=9A Mail=9A "D"=9A=9A string =9A=9A=9A=9A=9A Member=9A=9A=9A=9A=9A "2 D" string =9A=9A=9A=9A=9A member=9A=9A=9A=9A=9A "2 D" string =9A=9A=9A=9A=9A NoEmpl=9A=9A=9A=9A=9A 100=9A=9A int =9A=9A=9A=9A=9A OfficeHr=9A=9A=9A "M-Fr: 9.00-17.00"=9A=9A=9A=9A=9A = string =9A=9A=9A=9A=9A officeHr=9A=9A=9A "M-Fr: 9.00-17.00"=9A=9A=9A=9A=9A = string =9A=9A=9A=9A=9A Origin=9A=9A=9A=9A=9A "IE"=9A string =9A=9A=9A=9A=9A originCountry=9A=9A=9A=9A "IE"=9A string =9A=9A=9A=9A=9A printOptions=9A=9A=9A=9A=9A "1P"=9A string =9A=9A=9A=9A=9A Prtopt=9A=9A=9A=9A=9A "1P"=9A string =9A=9A=9A=9A=9A RegDate=9A=9A=9A=9A "2001"=9A=9A=9A=9A=9A string =9A=9A=9A=9A=9A regDate=9A=9A=9A=9A "2001"=9A=9A=9A=9A=9A string =9A=9A=9A=9A=9A regNo "123456N"=9A=9A string =9A=9A=9A=9A=9A RegNo "123456N"=9A=9A string =9A=9A=9A=9A=9A ReplyCodeId 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A replyCodeId 0=9A=9A=9A=9A int =9A=9A=9A=9A=9A Serial=9A=9A=9A=9A=9A "70950520"=9A string =9A=9A=9A=9A=9A serial=9A=9A=9A=9A=9A "70950520"=9A string =9A=9A=9A=9A=9A vatno ""=9A=9A=9A string =9A=9A=9A=9A=9A VatNo ""=9A=9A=9A string =20 =20 =20 ------_=_NextPart_001_01C7098F.AFC1BC52 Content-Type: text/html; charset="koi8-r" Content-Transfer-Encoding: quoted-printable

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=3D"GetCompanyById" resultMap=3D"CompaniesResultMap" parameterClass=3D"Hashtable">

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A select companyId,serial,regNo,regDate,legalFormId,

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A = vatno,originCountry,officeHr,employees,businessOverseas,

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A = printOptions,member,mail,indica,journl,comptr,isLocked,=9A=9A=9A=9A=9A = replyCodeId from companies

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A <isGreaterThan property =3D"CompanyId" compareValue =3D"0">=

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A = =9A=9A=9A=9A=9A where companyId =3D #CompanyId#

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A = </isGreaterThan> =

=9A=9A=9A=9A=9A = =9A=9A=9A=9A=9A =9A=9A=9A=9A=9A order by = companyId

=9A=9A=9A=9A=9A =9A=9A=9A=9A=9A </select>

……. ….

Then I = wrote a mapped class… with a method

public Company GetCompanyById(long companyId)

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = {=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A =

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A Company cp =3D new = Company();

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= =9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A try

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = {

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= Hashtable queryParams =3D new Hashtable();

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= queryParams.Add("CompanyId", companyId);

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= cp =3D = (Company)KompassMapper.Instance().QueryForObject("GetCompanyById&quo= t;,queryParams);

 

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = }

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A catch

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = {

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A= throw;

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = }

 

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A return = cp;

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A }

Unit test to invoke this = metnod:

[Test]

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A public void = GetWrongCompanyById()

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A {

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A CompaniesMap companyMap =3D new CompaniesMap();

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A //Company getCompany =3D new = Company();

 

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A Company company=3DcompanyMap.GetCompanyById(-1);

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A = Assert.AreEqual(0F,company.CompanyId);

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A =

=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A=9A }

Unit = test result is :

KompassDataLayer.Test.CompaniesTest.GetWrongCompanyById :

=9A=9A=9A=9A=9A expected: <0>

=9A=9A=9A=9A=9A =9Abut was: <29>

 

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

 

VS = watch :=9A cp

=9A=9A=9A=9A=9A BussOverseas=9A=9A=9A=9A=9A 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A bussOverseas=9A=9A=9A=9A=9A 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A changed=9A=9A=9A=9A false = bool

=9A=9A=9A=9A=9A Changed=9A=9A=9A=9A false = bool

=9A=9A=9A=9A=9A CompanyId=9A=9A 29=9A=9A=9A = long

=9A=9A=9A=9A=9A companyId=9A=9A 29=9A=9A=9A = long

=9A=9A=9A=9A=9A Comptr=9A=9A=9A=9A=9A null=9A = string

=9A=9A=9A=9A=9A comptr=9A=9A=9A=9A=9A null=9A = string

=9A=9A=9A=9A=9A emploees=9A=9A=9A 100=9A=9A = int

=9A=9A=9A=9A=9A Indica=9A=9A=9A=9A=9A "MSE" = string

=9A=9A=9A=9A=9A indica=9A=9A=9A=9A=9A "MSE" = string

=9A=9A=9A=9A=9A isLocked=9A=9A=9A false = bool

=9A=9A=9A=9A=9A Journl=9A=9A=9A=9A=9A "60"=9A = string

=9A=9A=9A=9A=9A journl=9A=9A=9A=9A=9A "60"=9A = string

=9A=9A=9A=9A=9A legalFormId 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A LegalFormId 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A Locked=9A=9A=9A=9A=9A false = bool

=9A=9A=9A=9A=9A mail=9A "D"=9A=9A = string

=9A=9A=9A=9A=9A Mail=9A "D"=9A=9A = string

=9A=9A=9A=9A=9A Member=9A=9A=9A=9A=9A "2 D" string

=9A=9A=9A=9A=9A member=9A=9A=9A=9A=9A "2 D" string

=9A=9A=9A=9A=9A NoEmpl=9A=9A=9A=9A=9A 100=9A=9A = int

=9A=9A=9A=9A=9A OfficeHr=9A=9A=9A "M-Fr: 9.00-17.00"=9A=9A=9A=9A=9A string

=9A=9A=9A=9A=9A officeHr=9A=9A=9A "M-Fr: 9.00-17.00"=9A=9A=9A=9A=9A string

=9A=9A=9A=9A=9A Origin=9A=9A=9A=9A=9A "IE"=9A = string

=9A=9A=9A=9A=9A originCountry=9A=9A=9A=9A "IE"=9A = string

=9A=9A=9A=9A=9A printOptions=9A=9A=9A=9A=9A "1P"=9A = string

=9A=9A=9A=9A=9A Prtopt=9A=9A=9A=9A=9A "1P"=9A = string

=9A=9A=9A=9A=9A RegDate=9A=9A=9A=9A = "2001"=9A=9A=9A=9A=9A string

=9A=9A=9A=9A=9A regDate=9A=9A=9A=9A = "2001"=9A=9A=9A=9A=9A string

=9A=9A=9A=9A=9A regNo "123456N"=9A=9A = string

=9A=9A=9A=9A=9A RegNo "123456N"=9A=9A = string

=9A=9A=9A=9A=9A ReplyCodeId 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A replyCodeId 0=9A=9A=9A=9A = int

=9A=9A=9A=9A=9A Serial=9A=9A=9A=9A=9A "70950520"=9A = string

=9A=9A=9A=9A=9A serial=9A=9A=9A=9A=9A "70950520"=9A = string

=9A=9A=9A=9A=9A vatno ""=9A=9A=9A = string

=9A=9A=9A=9A=9A VatNo ""=9A=9A=9A = string

 

 

 

------_=_NextPart_001_01C7098F.AFC1BC52--