ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Odd SQL Mapping error
Date Wed, 14 May 2008 15:00:51 GMT
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