ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: Odd SQL Mapping error
Date Wed, 14 May 2008 15:27:28 GMT
<from-the-interesting-discussion-department>

It's actually for ALL drivers... the setNull method has two parameters..
.the best you could hope to do by default is pass Types.OBJECT or
Types.NULL, but I've never seen it work..

This is one of the mysteries of the JDBC API that I've never understood.
Why does NULL of all things need a type?  And even if it does, why should
the driver and/or database of all things need to be told the type of a
column?  It's pretty funny, because an ORM would probably initially look up
the type from the database metadata and then at some point end up passing
that back to the driver in setNull....

Pretty strange

</from-the-interesting-discussion-department>

Cheers,
Clinton

On Wed, May 14, 2008 at 9:00 AM, Jeff Butler <jeffgbutler@gmail.com> wrote:

> For most drivers, you need to specify the JDBC type for nullable
> fields...like this:
>
> TITLE = #title:VARCHAR#
>
> Jeff Butler
>
>
>
> On Wed, May 14, 2008 at 9:53 AM, Chris O'Connell <
> oconnell@gorillachicago.com> wrote:
>
>>  When I am trying to execute an update through iBatis, I get a SQL
>> Exception: java.sql.SQLException: Invalid column type
>>
>>
>>
>> Here is the mapping:
>>
>> <update id="updateUserByUserID" parameterClass="User">
>>
>>         UPDATE USER_USERS SET
>>
>>             PASS = #pass#,
>>
>>             FIRST_NAME= #firstName#,
>>
>>             LAST_NAME = #lastName#,
>>
>>             TITLE = #title#,
>>
>>             COMPANY = #company#,
>>
>>             EMAIL = #email#,
>>
>>             DESCRIPTION = #description#,
>>
>>             USER_UUID = #uuid#,
>>
>>             MODIFY_DATE = sysdate,
>>
>>             SCREEN_NAME = #screenName#,
>>
>>             TRADE_PORTAL_ID = #tradePortalId#
>>
>>         WHERE
>>
>>             USER_ID = #userId#
>>
>>     </update>
>>
>>
>>
>> The error message is:
>>
>> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
>>
>> --- The error occurred in User.xml.
>>
>> --- The error occurred while applying a parameter map.
>>
>> --- Check the User.updateUserByUserID-InlineParameterMap.
>>
>> --- Check the parameter mapping for the 'title' property.
>>
>> --- Cause: java.sql.SQLException: Invalid column type
>>
>>
>>
>>
>>
>> What is happening is that I have a unit test that selects the user out of
>> the database, updates an attribute on the User object and then calls a
>> method to execute the 'updateUserByUserID' sql statement.  I checked the
>> database (Oracle) and the datatype of the TITLE column is "VARCHAR2(200)".
>> The type of the 'title' attribute on the User class is "String".  So, the
>> record in the database has "null" as the value of the TITLE, and I don't
>> update that in my code, so what I am trying to do is just set the TITLE back
>> to null in the update statement.  I am pretty sure that the 'setting back to
>> null' is what is causing the problem, because if I change the code so that I
>> explicitly set the title attribute to a non-null value and re-run the test,
>> I get the same error message, except the property changes so that I need to
>> check the parameter mapping for the 'company' property.
>>
>>
>>
>> I'm guessing that I am missing something simple, but I have been looking
>> at this and my eyes are starting to cross.  Thanks for any help.
>>
>>
>>
>> Chris
>>
>>
>

Mime
View raw message