Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 77503 invoked from network); 3 Sep 2007 17:51:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Sep 2007 17:51:43 -0000 Received: (qmail 5366 invoked by uid 500); 3 Sep 2007 17:51:32 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 5344 invoked by uid 500); 3 Sep 2007 17:51:32 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 5333 invoked by uid 99); 3 Sep 2007 17:51:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2007 10:51:32 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of larry.meadors@gmail.com designates 64.233.182.184 as permitted sender) Received: from [64.233.182.184] (HELO nf-out-0910.google.com) (64.233.182.184) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2007 17:51:28 +0000 Received: by nf-out-0910.google.com with SMTP id b2so1381477nfb for ; Mon, 03 Sep 2007 10:51:07 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=mFNRI9bwaiD9SPlNKhbvK0YQ60/Ti+ykVdPDaGvHbrWB/bXGyewuUNUEwBDtk40sywI4u5MHwovqydBpUGNhkcOPJ78zp77Lan7kP7BzGHl0k0ln5pNhYwt5sciiWQX1x+2O8BgucfBSSjHXYvwA+HMHL+7xbprjKehl6CAB04Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=neEwvwqMH1fW1K/vyhbEhRBdhgou/+i3VxF5cIcuFgVDsui4vdnfFgl7ynWJ8y/QMD9wbpgFAQ0XjIbj9UwNXuNkRuJjH5S7a+o1afLiM1ewVqCpFSdE8w56TcglTLsIhwJ21VaqcnQ5B30cjaJVcAns7xHq5zBduQowy9fTnn0= Received: by 10.78.162.4 with SMTP id k4mr3437730hue.1188841866289; Mon, 03 Sep 2007 10:51:06 -0700 (PDT) Received: by 10.78.143.9 with HTTP; Mon, 3 Sep 2007 10:51:06 -0700 (PDT) Message-ID: Date: Mon, 3 Sep 2007 11:51:06 -0600 From: "Larry Meadors" Reply-To: lmeadors@apache.org Sender: larry.meadors@gmail.com To: user-java@ibatis.apache.org Subject: Re: JavaBean and Map parameters In-Reply-To: <46DC39AE.7040305@fh-joanneum.at> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <46D8473C.8040300@fh-joanneum.at> <46DBC21A.5000307@fh-joanneum.at> <46DC39AE.7040305@fh-joanneum.at> X-Google-Sender-Auth: 8a15fba5b218cead X-Virus-Checked: Checked by ClamAV on apache.org Heh, I think I wrote that part. :-) You can't reliably refer to an *anonymous* inner class by name (hence the anonymous part - IIRC, they are assigned names by location MyClass$1, MyClass$2, etc), so you can't safely put the name in your mapped statement, so iBATIS doesn't do that load time checking (because it doesn't know the parameter class name). For load time checking to work, the parameter class name has to be associated with the mapped statement (either as an explicit parameter map, or a parameterClass attribute). Larry On 9/3/07, Ilya Boyandin wrote: > > Hi Larry, > > Larry Meadors wrote: > > I don't know about the performance - a hashmap is pretty fast for > > retrieval. (FYI: the constructor you use there will cause slower > > performance - the default would use more memory, but be faster - using > > 3 or 4 as the parameter might be better, read the javadocs on that > > one.) > > > Oh sure, I forgot about the .75 load factor. Thanks for telling me this! > I agree in this case it's better not to use the parameter at all. > > > The parameter checking is an interesting idea - I'm just not sure that > > it makes it much less error prone - in both cases, you need to type > > (or paste) the names. > > > It's not my idea, actually. I found it in the section "JavaBean and Map > parameters" of "iBatis in Action". It sais: > "If you create a parameter map with a bean and attempt to refer to a > property that does not exist, you will get an immediate failure when the > parameter map is loaded." I tested it now with the anonymous parameter > class I cited before and it doesn't seem to work as described: the > "There is no READABLE property named" exception is thrown only when the > query is called, not when the map is loaded. I think I got something > wrong again :) > > Regards > Ilya > > > > On 9/3/07, Ilya Boyandin wrote: > > > >> Thanks, Larry! > >> > >> but could you tell me why? I thought using an anonymous class has an > >> important advantage: it allows loading-time parameter check. Also I > >> think it should be faster than using HashMap. Isn't it true? > >> > >> Ilya > >> > >> Larry Meadors wrote: > >> > >>> Well, they should both do the same thing...I'd use the map. :) > >>> > >>> Larry > >>> > >>> > >>> On 8/31/07, Ilya Boyandin wrote: > >>> > >>> > >>>> Hello all, > >>>> > >>>> what should I prefer, this: > >>>> > >>>> return getSqlMapClientTemplate().queryForList("listEvaluationPlans",= new > >>>> Object() { > >>>> long getPersonId() { return personId; } > >>>> String getLang() { return lang; } > >>>> }); > >>>> > >>>> or this: > >>>> > >>>> final Map params =3D new HashMap(2); > >>>> params.put("personId", personId); > >>>> params.put("lang", lang); > >>>> return getSqlMapClientTemplate().queryForList("listEvaluationPlans", > >>>> params); > >>>> > >>>> Thanks in advance > >>>> Ilya > >>>> > >>>> > > > > FH JOANNEUM Gesellschaft mbH > Rechtsform/Legal form: GmbH > Firmenbuchgericht/Court of registry: Landesgericht f=FCr ZRS Graz > Firmenbuchnummer/Company registration: FN 125888 f > DVR: 0813559 > UID-Nr.: ATU 42361001 >