This only holds when the bean-class is explicitly specified, i.e. it must not be an anonymous class. If it's anonymous, iBATIS has no way to inspect the bean class, since it's unknown at load-time.
Niels -----Original Message----- From: Ilya Boyandin [mailto:[EMAIL PROTECTED] Sent: maandag 3 september 2007 18:43 To: user-java@ibatis.apache.org Subject: Re: JavaBean and Map parameters 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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<String, Object> params = new HashMap<String, Object>(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ür ZRS Graz Firmenbuchnummer/Company registration: FN 125888 f DVR: 0813559 UID-Nr.: ATU 42361001