Dao
int updateByOutstorage(List<Cargolist> cargolist);
Mapper.xml
这里注意添加foreach节点的操作符,open和close
否则Mybatis不能识别这是批量操作的多条语句,就会报ORA-00911: 无效字符
<update id="updateByOutstorage" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
update ware_cargolist
<set>
OUTDATE = sysdate
</set>
where CARGONO = #{item.cargono,jdbcType=VARCHAR}
and OUTDATE is null
</foreach>
</update>
博客主要讲述在使用MyBatis操作Oracle数据库时,在Dao和Mapper.xml中进行批量操作的注意事项。强调在Mapper.xml里添加foreach节点的操作符open和close,否则MyBatis无法识别批量操作的多条语句,会报ORA - 00911无效字符错误。
3364

被折叠的 条评论
为什么被折叠?



