ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <lmead...@apache.org>
Subject Re: iBATIS strange behaviour
Date Thu, 06 Oct 2005 14:37:31 GMT
Hmm, this seems really odd. The code that is in SVN now supports
properties named like "sProperty" with mutators like "getsProperty"
and "setsProperty".

According to the beans specification, getters named "getSProperty" and
"setSProperty" define a property named "SProperty", not "sProperty" as
you might expect. (BTW, the iBATIS in SVN does that, too).

OK, I answered the first two questions...someone else gets the last one. ;-)

Two questions for you:
 - How are your getter/setter methods named?
 - What version of iBATIS are you using?

Larry


On 10/6/05, Pere Torrodellas <ptorrodellas@fihoca.com> wrote:
> I ran into this strange problem that required a lot of time to debug. This
> is just to try to save trouble for those that run into it.
>
> iBATIS version: 2.1.5
>
> This first data map works OK:
>
> <typeAlias alias="Oferta" type="gov.soc.web.model.ofertes.Oferta"/>
> <select id="getOferta" parameterClass="java.lang.Integer"
> resultClass="Oferta">
>     select
>         ID_OFERTA as iIdOferta,
>         OCUPACIO as stOcupacio,
>         MUNICIPIO as stLocalitat
>     from OFERTAS
>     where ID_OFERTA = #value#
> </select>
>
> But this one throws an exception:
>
> <typeAlias alias="Oferta" type="gov.soc.web.model.ofertes.Oferta"/>
> <resultMap id="getOfertaResult" class="Oferta">
>     <result property="iIdOferta" column="ID_OFERTA"/>
>     <result property="stOcupacio" column="OCUPACIO"/>
>     <result property="stLocalitat" column="MUNICIPIO"/>
> </resultMap>
> <select id="getOferta" parameterClass="java.lang.Integer"
> resultMap="getOfertaResult">
>    select
>        ID_OFERTA,
>        OCUPACIO,
>        MUNICIPIO
>    from OFERTAS
>    where ID_OFERTA = #value#
> </select>
>
> Note that result class, property names and table are the same in both cases.
>
> The exception says:
>
> com.ibatis.common.beans.ProbeException: There is no WRITEABLE property named
> 'iIdOferta' in class 'gov.soc.web.model.ofertes.Oferta'
>
> ...which is wrong because I checked umpteen times property name and setter
> method, and what's more: it works with the first data map format.
>
> Commenting out the <result> tag for the iIdOferta property, the second data
> map format also works OK.
>
> After many, many tests and Mail Archive searches, I tried in despair a last
> one: I changed the property name from iIdOferta to inIdOferta, together with
> its getter/setter... IT WORKED!!!
>
> So... is this an iBATIS bug? Doesn't it like property names that start with
> a lowercase letter followed by an uppercase letter? If so, why does it work
> with the first data map format? Can someone offer an explanation?
>
> Just be warned.
>
> Regards,
>
> Pere
>
>
>
>

Mime
View raw message