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 Jim Newsham <ne...@hawaii.rr.com> on 2005/06/14 00:43:15 UTC
configured type handler not used in insert
Hi,
We just recently started using iBatis. We're using version 2.1.0. We
have a few fields whose types are not the basic, built-in supported
types. We discovered that we can implement a TypeHandlerCallback for
each such type. The type handlers are defined in SqlMapConfig, such as:
<typeHandler javaType='java.lang.Boolean' jdbcType='CHAR'
callback='com...BooleanTypeHandler'/>
With this handler installed, the type conversion is done automatically
for queries. But for inserts, the type conversion is not called (this
is confirmed with some debug statements in the type handler). The
result is a null pointer exception.
I discovered that we can include an explicit, inline type handler within
the insert map (such as #private,handler=com...BooleanTypeHandler#).
This is the workaround we're using for now, but the question is, why is
this explicit mapping necessary when the type handler has been declared
to handle all boolean types, as shown above?
(P.S.: Not sure if this stuff is documented here; here are some
references I found:
http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+Custom+Type+Handler+with+complex+property+or+Type+Safe+Enumeration%3F
http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg00570.html
)
Thanks,
Jim
Re: configured type handler not used in insert
Posted by Clinton Begin <cl...@gmail.com>.
Hmm...might be a bug. Best to log a JIRA issue for this one and we'll look
into it.
Cheers,
Clinton
On 6/13/05, Jim Newsham <ne...@hawaii.rr.com> wrote:
>
>
> Hi,
>
> We just recently started using iBatis. We're using version 2.1.0. We
> have a few fields whose types are not the basic, built-in supported
> types. We discovered that we can implement a TypeHandlerCallback for
> each such type. The type handlers are defined in SqlMapConfig, such as:
>
> <typeHandler javaType='java.lang.Boolean' jdbcType='CHAR'
> callback='com...BooleanTypeHandler'/>
>
> With this handler installed, the type conversion is done automatically
> for queries. But for inserts, the type conversion is not called (this
> is confirmed with some debug statements in the type handler). The
> result is a null pointer exception.
>
> I discovered that we can include an explicit, inline type handler within
> the insert map (such as #private,handler=com...BooleanTypeHandler#).
> This is the workaround we're using for now, but the question is, why is
> this explicit mapping necessary when the type handler has been declared
> to handle all boolean types, as shown above?
>
> (P.S.: Not sure if this stuff is documented here; here are some
> references I found:
>
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+Custom+Type+Handler+with+complex+property+or+Type+Safe+Enumeration%3F
>
> http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg00570.html
> )
>
> Thanks,
>
> Jim
>
>