Error setting null for parameter #2 with JdbcType OTHER

mybatis执行时报错内容如下:


Error setting null for parameter #2 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111

MyBatis 插入空值时,需要指定JdbcType

解决办法:
<insert id="add" parameterType="Customer">
insert into LG_CUSTOMER(id,
customerCode,
organization,
logo,
customerName,
shorthandCode,
createDate)
 values(#{id,jdbcType=VARCHAR},
       #{customerCode,jdbcType=VARCHAR},
        #{organization,jdbcType=VARCHAR},
         #{logo,jdbcType=VARCHAR},
       #{customerName,jdbcType=VARCHAR},
       #{shorthandCode,jdbcType=VARCHAR},
       #{createDate,jdbcType=VARCHAR})
</insert>

版权声明:本文为qq_30776829原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。