Mybatis实现Oracle批量插入

wozuiaijiahui wozuiaijiahui 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
之前用的SqlSessionDaoSupport,但是网上搜了下,发现getSqlSession()不能设置ExecutorType,所以又自己重写了一个类,为SqlSession设置了ExecutorType,Mapper里使用
<insert id="insertBatch" >
insert into student ( <include refid="Base_Column_List" /> )
values
<foreach collection="list" item="item" index="index" separator=",">
(null,#{item.name},#{item.sex},#{item.address},#{item.telephone},#{item.tId})
</foreach>
</insert>
会报错,ORA-00933: SQL 命令未正确结束,ORACLE应该不支持这种写法吧,然后改成这样

<insert id="insertBatch" >
<foreach collection="list" item="item" index="index" separator=",">
insert into student ( <include refid="Base_Column_List" /> )
values
(null,#{item.name},#{item.sex},#{item.address},#{item.telephone},#{item.tId})
</foreach>
</insert>
还是报错,谁遇到过这种情况,帮忙看下,多谢了,另外问下mybaits这种批量插入的方式如果用SPRING管理事物,中途插入异常会回滚吗?
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
wozuiaijiahui
Java EE 67,535 成员 225,843 内容