You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Nathan Maves <na...@gmail.com> on 2010/01/28 18:45:56 UTC

Re: Little question about type check between resultMap and java return type

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 <ma...@gmail.com>

Nathan Maves
nathan.maves@gmail.com