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 Anthony Hong <an...@gmail.com> on 2006/11/22 01:23:35 UTC

How to convert data type in java code with ibatis framework

I have a common table that stores data with id and value.
The value field defined in DB is varchar2.
Currently each time I store or retrieve data from db, I convert value
from object to string in inserting, updating. Or convert value from
string to objec in selectinig.
I'd like to know how to achieve with ibatis help, something like
before paremeter set I can do something. Or in result map. I can do
convertion.

-- 

Anthony Hong

Re: How to convert data type in java code with ibatis framework

Posted by Anthony Hong <an...@gmail.com>.
Looks like your suggestion can help me.
If this problem can be solved, then I think it works.
The problem is:
ResultGetter in TypeHandlerCallback only works with one filed, how to
conjuction with another field.
Say my dynamic object has one property save value and one property
save its class type.
How to do convertion in typehandler that I can access another property in class?

I save examples are all about enumation class. If I define its to
handle with java.lang.Object, all other specific data type handler
with not be used anymore?


On 11/22/06, Caio Zanchetti <ca...@gmail.com> wrote:
> Hi, I don't know if I could understand very well your question, but you can
> define an "extension" through the TypeHandlerCallback class implementation.
> Than you will can automatic convert between two types.
>
> Regards,
>
>
>
>
> On 11/21/06, Anthony Hong <an...@gmail.com> wrote:
> > I have a common table that stores data with id and value.
> > The value field defined in DB is varchar2.
> > Currently each time I store or retrieve data from db, I convert value
> > from object to string in inserting, updating. Or convert value from
> > string to objec in selectinig.
> > I'd like to know how to achieve with ibatis help, something like
> > before paremeter set I can do something. Or in result map. I can do
> > convertion.
> >
> > --
> >
> > Anthony Hong
> >
>
>
>
> --
> Claudiomir G. Zanchetti (Caio)
> Sun Certified Programmer for the Java 2 Plataform, Standard Edition 5.0


-- 

Anthony Hong

Re: How to convert data type in java code with ibatis framework

Posted by Caio Zanchetti <ca...@gmail.com>.
Hi, I don't know if I could understand very well your question, but you can
define an "extension" through the TypeHandlerCallback class implementation.
Than you will can automatic convert between two types.

Regards,



On 11/21/06, Anthony Hong <an...@gmail.com> wrote:
>
> I have a common table that stores data with id and value.
> The value field defined in DB is varchar2.
> Currently each time I store or retrieve data from db, I convert value
> from object to string in inserting, updating. Or convert value from
> string to objec in selectinig.
> I'd like to know how to achieve with ibatis help, something like
> before paremeter set I can do something. Or in result map. I can do
> convertion.
>
> --
>
> Anthony Hong
>



-- 
Claudiomir G. Zanchetti (Caio)
Sun Certified Programmer for the Java 2 Plataform, Standard Edition 5.0