mybatis + oracle insert clob,出现ORA-01461:仅能绑定要插入LONG列的LONG值

在网上查了很久,有可能问题是出现在当从dual中取数据时,会将clob对象的字段转为Long型

最后的解决方法用到了Begin和end语法:

1.用到begin 和end

2.用到insert into value()语法

不能用insert into select from dual (union all)语法

3.参数,指定 jdbcType=CLOB 类型

 <insert id="batchInsert" parameterType="java.util.List">
    begin
    <foreach collection="list" item="item" index="index" separator=";">
       insert into tableName(ID, content) 
       values( #{item.id},#{item.content,jdbcType=CLOB})
    </foreach> 
    ;end;
  </insert>

 

posted @ 2018-01-30 13:05  君子笑而不语  阅读(5512)  评论(0编辑  收藏  举报