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 em...@tomashula.cz on 2010/02/15 08:43:40 UTC

TypeHandlerCallback isn't called when target is HashMap

Hi all,

I am dealing with one problem regarding type handlers. I created my own
type handler for java.sql.Timestamp and I added the following line to
SqlMapConfig.xml:

<typeHandler javaType="java.sql.Timestamp"
callback="some_package.TimestampHandler" />

This handler works right when I load DB records into objects with defined
classes (i.e. resultClass="SomeClass") or when I use result map and define
the java type directly (i.e. javaType="java.sqlTimestamp" in result
element).

But the handler doesn't apply when I loading DB records into simply
HashMap (i.e. resultClass="HashMap"). In this case my handler isn't used
and as I found out, a handler for java.lang.Object is used instead. But
the corresponding field in hash map is correctly of type
java.sql.Timestamp.

Please, is it a bug or is it a logical approach that I just don't
understand to? Is there any other possibility than writing my own handler
for java.lang.Object or defining result maps for all selects?

I found similar item here
(http://www.mail-archive.com/user-java@ibatis.apache.org/msg11954.html)
but with no reply.

Thanks a lot in advance,
Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: TypeHandlerCallback isn't called when target is HashMap

Posted by Tomáš Hula <em...@tomashula.cz>.
I am using version 2.3.4.726 and I believe it's the latest version (apart
from 3.x versions). Should it be fixed in this version or did you mean 3.x
versions?

Thanks,
Tom

On 15.2.2010 14:53, Clinton Begin wrote:
> I believe this was a big and was fixed... What version are you using?
>
> 2010/2/15 <email@tomashula.cz <ma...@tomashula.cz>>
>
>     Hi all,
>
>     I am dealing with one problem regarding type handlers. I created
>     my own
>     type handler for java.sql.Timestamp and I added the following line to
>     SqlMapConfig.xml:
>
>     <typeHandler javaType="java.sql.Timestamp"
>     callback="some_package.TimestampHandler" />
>
>     This handler works right when I load DB records into objects with
>     defined
>     classes (i.e. resultClass="SomeClass") or when I use result map
>     and define
>     the java type directly (i.e. javaType="java.sqlTimestamp" in result
>     element).
>
>     But the handler doesn't apply when I loading DB records into simply
>     HashMap (i.e. resultClass="HashMap"). In this case my handler
>     isn't used
>     and as I found out, a handler for java.lang.Object is used
>     instead. But
>     the corresponding field in hash map is correctly of type
>     java.sql.Timestamp.
>
>     Please, is it a bug or is it a logical approach that I just don't
>     understand to? Is there any other possibility than writing my own
>     handler
>     for java.lang.Object or defining result maps for all selects?
>
>     I found similar item here
>     (http://www.mail-archive.com/user-java@ibatis.apache.org/msg11954.html)
>     but with no reply.
>
>     Thanks a lot in advance,
>     Tom
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>     <ma...@ibatis.apache.org>
>     For additional commands, e-mail: user-java-help@ibatis.apache.org
>     <ma...@ibatis.apache.org>
>
>


Re: TypeHandlerCallback isn't called when target is HashMap

Posted by Clinton Begin <cl...@gmail.com>.
I believe this was a big and was fixed... What version are you using?

2010/2/15 <em...@tomashula.cz>

> Hi all,
>
> I am dealing with one problem regarding type handlers. I created my own
> type handler for java.sql.Timestamp and I added the following line to
> SqlMapConfig.xml:
>
> <typeHandler javaType="java.sql.Timestamp"
> callback="some_package.TimestampHandler" />
>
> This handler works right when I load DB records into objects with defined
> classes (i.e. resultClass="SomeClass") or when I use result map and define
> the java type directly (i.e. javaType="java.sqlTimestamp" in result
> element).
>
> But the handler doesn't apply when I loading DB records into simply
> HashMap (i.e. resultClass="HashMap"). In this case my handler isn't used
> and as I found out, a handler for java.lang.Object is used instead. But
> the corresponding field in hash map is correctly of type
> java.sql.Timestamp.
>
> Please, is it a bug or is it a logical approach that I just don't
> understand to? Is there any other possibility than writing my own handler
> for java.lang.Object or defining result maps for all selects?
>
> I found similar item here
> (http://www.mail-archive.com/user-java@ibatis.apache.org/msg11954.html)
> but with no reply.
>
> Thanks a lot in advance,
> Tom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>