ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Maves <nathan.ma...@gmail.com>
Subject Re: Little question about type check between resultMap and java return type
Date Thu, 28 Jan 2010 17:45:56 GMT
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.


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

Nathan Maves

View raw message