ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-494) ClobTypeHandlerCallback handles NULLs incorrectly
Date Tue, 11 Mar 2008 20:24:47 GMT

    [ https://issues.apache.org/jira/browse/IBATIS-494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577589#action_12577589

Jeff Butler commented on IBATIS-494:

Interesting and convoluted.

Every type handler except the Blob and Clob type handlers call the "wasNull()" function to
determine if the returned value was null.  This seems to me like the proper way to fix this
in the getResult() methods of those two type handlers.

None of the other type handlers call the setNull() function, although I think they probably
should.  For most other type handlers, there is other code in iBATIS that does a null check
before calling the type handler and calls the appropriate setNull() function (see com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap,
the setParameter method).  This check does not apply to the BLOB or CLOB handlers because
they turn out to be implementations of CustomTypeHandler.

Long story.

So, will you verify that calling wasNull() in the getResult() method works in your instance
(instead of the method you use in your patch)?  See any other type handler for an example
of how to implement this.  If it works (as I think it should), I'll commit the change (and
fix some of the other type handlers too while I'm at it).

> ClobTypeHandlerCallback handles NULLs incorrectly
> -------------------------------------------------
>                 Key: IBATIS-494
>                 URL: https://issues.apache.org/jira/browse/IBATIS-494
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.3.0
>         Environment: WebSphere Application Server 6, DB2/390
>            Reporter: Aaron Craven
>         Attachments: ClobTypeHandlerCallback.diff
> After getting some very strange corruption issues with CLOBs in our production environment,
I did some digging and I believe ClobTypeHandlerCallback to be improperly handling NULLs (though
I'm not sure). The attached patch fixed our problem. 
> Please note that I believe our corruption issues to be aggravated by a poorly implemented
JDBC driver. I certainly don't think iBatis is corrupting our CLOB fields directly. But still,
I believe these changes more properly handle values in CLOBs.
> There are two main modifications:
> - in getResult(), the method was defaulting to an empty string if the CLOB was null.

> - in setParameter, I replaced setString(null) with setNull(Types.CLOB), which I believe
to be a more appropriate way to set a column to null in most drivers.
> As I said, I'm not a JDBC expert, so I could be wrong on these changes.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message