您的位置:首页 > 其它

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

2013-07-09 13:30 405 查看
报错内容:
### Cause: org.apache.ibatis.type.TypeException: Error settingnull for parameter #10 with JdbcType OTHER . Try setting adifferent JdbcType for this parameter or a differentjdbcTypeForNull configuration property. Cause:java.sql.SQLException: 无效的列类型

MyBatis 插入空值时,需要指定JdbcType
mybatisinsert空值报空值异常,但是在pl/sql不会提示错误,主要原因是mybatis无法进行转换,

解决方法:

在insert语句中,增加jdbcType解决问题

<insert id="save"parameterType="Province">
  <![CDATA[
  insert into t_yp_province
 (fid,fname,fnumber,fsimpleName,fdescription,fcreateTime,flastUpdateTime,fdirect)
  values
  ( #{id,jdbcType=VARCHAR},
  #{name,jdbcType=VARCHAR},
  #{number,jdbcType=VARCHAR},
  #{simpleName,jdbcType=VARCHAR},
  #{description,jdbcType=VARCHAR},
  #{createTime,jdbcType=DATE},
  #{lastUpdateTime,jdbcType=DATE},
  #{direct,jdbcType=NUMERIC}
  )  
  ]]>
 </insert>;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: