mybatis批量更新 使用动态表和字段

来源:互联网 发布:淘宝有卖二手丝袜吗 编辑:程序博客网 时间:2024/05/29 10:37

使用mybatis 批量更新在使用动态表和字段的时候要注意以下几点,否则会报 ORA-06550: 第 3 行, 第 11 列: PL/SQL: ORA-00903: 表名无

         (1)添加属性statementType="STATEMENT

     (2)同时sql里的属有变量取值都改成${xxxx},而不是#{xxx}

以上缺一不可

例如以下批量更新语句:传入参数为list<map>类型

<update id="updateTempValue" parameterType="java.util.List" statementType="STATEMENT">     <foreach collection="list" item="item" index="index" open="begin" close="end;" separator="" >        update${item.DTABLE} set              ${item.content}           where column=${item.field};     </foreach>   </update>
若写成如下形式就会报错
<update id="updateTempValue" parameterType="java.util.List">     <foreach collection="list" item="item" index="index" open="begin" close="end;" separator="" >        update #{item.DTABLE} set           #{item.content}           where column=#{item.field};     </foreach>   </update>


参考:http://blog.csdn.net/yin_jw/article/details/27193317


0 0