ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Speranza <marco.speranz...@gmail.com>
Subject Re: Re: Little question about type check between resultMap and java return type
Date Thu, 28 Jan 2010 19:15:15 GMT
Hi Nathan

tnx for you reply,
A strict type checking is a good feature to minimize the errors.
Are you planning to implement this check in the future?

Thanks a lot.




This is a known "feature" of ibatis 3 :)
>
> We have been talking about it but nothing has really come of it.  The truth is
> that the result class you are using must have, at least, the same properties
> that are being returned.  My current opinion is that we should have strict type
> checking on result classes.
>
> Nathan
>
> On Jan 28, 2010, at 7:07 AM, Marco Speranza wrote:
>
> > Hi all
> >
> > I have notice an unusual behaviour of ibatis result object mapping.
> > Mapping a query result with a wrong ResultMap, no error is thrown.
> >
> >
> > My xml mapper is:
> >
> > <select id="getSizeItems" resultMap="SizeResult">
> >     SELECT
> >             SIZE_ID,
> >             DESCRIPTION
> >     FROM MY_TABLE
> > </select>
> >
> > My resultMap into xml file is:
> >
> > <resultMap type="JavaBeanOne" id="SizeResult">
> >    <result column="ID" property="name" />
> >    <result column="LOCATION" property="position" />
> > </resultMap>
> >
> > and my java interface is:
> >
> > public List < JavaBeanTwo > getSizeItems() throws SQLException;
> >
> > The error is that the related java type for the result map, 'SizeResult', is
> > different from  the one specified into interface method signature.
> > Furthermore no column returned from the Select statement matched related
> > ResultMap.
> > For this scenario ibatis returns a list of items filled with null object, the
> > number of elements was the one retrieved from database.
> > I will like to know if that is the right behaviour of ibatis.
> >
> > How can I catch the bugs derived from wrong mapping ?
> >
> > Thanks a lot.
> >
> >
> >
> > --
> > Marco Speranza <marco.speranz...@gmail.com>
>
> Nathan Mavesnathan.ma...@gmail.com
>
>
-- 
Marco Speranza <marco.speranza79@gmail.com>

Mime
View raw message