ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: IBatis 3 TypeHandler resolution
Date Tue, 22 Sep 2009 23:28:39 GMT
No, that's actually correct.  If you specify  the JDBC type in the type
handler, then you have to specify it in the result map.  However, if you
don't specify the JDBC type in either, that should work too, but will
override ALL string types (for example).
The reason is that iBATIS doesn't introspect the column type at runtime.

Clinton

On Tue, Sep 22, 2009 at 4:10 PM, Guy Rouillier <guyr-ml1@burntmail.com>wrote:

> I'm new to iBatis and writing my first type handler to map a database
> column to an enum whose underlying type is integer.  I've got it working
> after falling prey to some Java limitations (can't extend enum, can't define
> static methods in interfaces, the combination of which seems to prevent me
> from writing a generalized type handler for all integer-based enums.)
>
> However, I'm a little confused as to how type handlers get mapped.  Here is
> my entry in the iBatisConfig.xml file (shortened for readability):
>
>   <typeHandlers>
>      <typeHandler javaType="OrderStatusEnum" jdbcType="VARCHAR"
> handler="OrderStatusEnumTypeHandler"/>
>   </typeHandlers>
>
> Through trial and error, I discovered that in order to have iBatis apply
> this type handler, in the resultMap result entry I had to specify both
> javaType and jdbcType.  If I supplied only javaType, then iBatis applied the
> default enumTypeHandler (unsuccessfully).
>
> I then found that if I supply typeHandler on the result entry in the
> resultMap, I can dispense with the typeHandler declaration in iBatisConfig,
> and also dispense with javaType and jdbcType in the result entry.  That's
> less typing and accomplishes the same thing.
>
> Am I missing something? (Likely).
>
> Thanks.
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message