Difference between TypeHandler and TypeHandlerCallback

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Difference between TypeHandler and TypeHandlerCallback

jaybytez
I have been using TypeHandler for creating custom datatype handlers.

But how is this class different than TypeHandlerCallback.  I notice that TypeHandlerCallback uses ParameterSetter and ResultGetter.  Is the difference between these two and their usage based on whether you want to use ParameterSetter/ResultGetter for better reusability of those classes?

Thanks,

jay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Difference between TypeHandler and TypeHandlerCallback

Clinton Begin
TypeHandlerCallback is just easier to implement.  They are otherwise pretty much the same.

Going forward, for an iBATIS 3 test design, I've gone with the TypeHandlerCallback design exclusively. 

Cheers,
Clinton

On 7/26/06, jaybytez <[hidden email]> wrote:

I have been using TypeHandler for creating custom datatype handlers.

But how is this class different than TypeHandlerCallback.  I notice that
TypeHandlerCallback uses ParameterSetter and ResultGetter.  Is the
difference between these two and their usage based on whether you want to
use ParameterSetter/ResultGetter for better reusability of those classes?

Thanks,

jay
--
View this message in context: http://www.nabble.com/Difference-between-TypeHandler-and-TypeHandlerCallback-tf2006318.html#a5511501
Sent from the iBATIS - User - Java forum at Nabble.com.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Difference between TypeHandler and TypeHandlerCallback

jaybytez
So does that mean that in the current version of iBatis...TypeHandlerCallback can be used with the callback attribute in the sqlMapConfig file as well as with the typeHandler attribute in the sqlMap file?

Thanks...I just want to know so that I can convert my handlers.

jay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Difference between TypeHandler and TypeHandlerCallback

Clinton Begin

Either of them can be used in either place. 

It's a matter of preference.  If you like the TypeHandler API better than the TypeHandlerCallback API...then feel free to use it.

It won't be changing in 2.0, and neither will be compatible with 3.0 (but migration will be simple from either).

Cheers,
Clinton

On 7/26/06, jaybytez <[hidden email]> wrote:

So does that mean that in the current version of iBatis...TypeHandlerCallback
can be used with the callback attribute in the sqlMapConfig file as well as
with the typeHandler attribute in the sqlMap file?

Thanks...I just want to know so that I can convert my handlers.

jay
--
View this message in context: http://www.nabble.com/Difference-between-TypeHandler-and-TypeHandlerCallback-tf2006318.html#a5512050
Sent from the iBATIS - User - Java forum at Nabble.com.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Duplicate typeHandler (same javaType, different jdbcType)

jaybytez
Last question on this before I drive you crazy.

TypeHandler gives me accessibility to the SQL Type so I know if the user is using the typeHandler for two different SQL data types and perform the necessary get/set based on that type.  For instance, Date and Timestamp correlate to the same object DateTime (in my application).  So if the type that is required is a sql Date...I can do the proper get/set for SQL Date, and likewise for Timestamp.  With TypeHandlerCallback...I will not have that accessibility.  So if I create a DateTime/Timestamp handler callback and DateTime/Date handler callback...can I register both in the sqlMapConfig?  Or would iBatis not know what conversion to do when it hits a DateTime object?

Current Code:
        <typeHandler javaType="com.healthnet.hnfs.common.util.DateTime"
                callback="com.foo.dao.datahandler.DateTimeTypeHandler"/>

Future Code:

        <typeHandler jdbcType="TIMESTAMP" callback="com.foo.dao.datahandler.DateTimeTypeHandler"/>
        <typeHandler jdbcType="DATE" callback="com.foo.dao.datahandler.DateTimeTypeHandler"/>

Is this correct?  Without stating the javaType for duplication?

Thanks,

jay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Difference between TypeHandler and TypeHandlerCallback

kpsh
In reply to this post by jaybytez
 I need to use Oracle Objects in calling oracle stored procedure using Ibatis 2.5.4. I do not have good example of handling this situation. Could you be kind enough to point me in the right direction using few examples please ?
Loading...