关于mybatis批量插入的问题
自己写的一个批量插入的方法
@Override
public void batchAdd(List<SnapshotDf> list) {
getSqlSession().insert(this.getClassName()+".batchAdd",list);
}
对应的map
<insert id="batchAdd" parameterType="java.util.List">
insert into snapshot_df(
link_id,
sid,
df_name,
df_storage,
df_used,
df_free,
df_usage,
df_mount,
record_time
)values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.linkId},
#{item.sid},
#{item.dfName},
#{item.dfStorage},
#{item.dfUsed},
#{item.dfFree},
#{item.dfUsage},
#{item.dfMount},
#{item.recordTime}
)
</foreach>
</insert>
可是为什么通过后台日志发现拼成的执行sql是
select count(1) from (insert into snapshot_df(...)...
为什么会多出select count(1) from这样一句呢?
@Override
public void batchAdd(List<SnapshotDf> list) {
getSqlSession().insert(this.getClassName()+".batchAdd",list);
}
对应的map
<insert id="batchAdd" parameterType="java.util.List">
insert into snapshot_df(
link_id,
sid,
df_name,
df_storage,
df_used,
df_free,
df_usage,
df_mount,
record_time
)values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.linkId},
#{item.sid},
#{item.dfName},
#{item.dfStorage},
#{item.dfUsed},
#{item.dfFree},
#{item.dfUsage},
#{item.dfMount},
#{item.recordTime}
)
</foreach>
</insert>
可是为什么通过后台日志发现拼成的执行sql是
select count(1) from (insert into snapshot_df(...)...
为什么会多出select count(1) from这样一句呢?
...全文
相关推荐
MyBatis批量插入Update
需要注意的是,MyBatis批量插入可能会出现内存不足的问题,因此需要提前修改MySql的配置文件,增加max_allowed_packet的值以避免内存不足的问题。
mybatis 批量插入 嵌套select.pdf
这个问题的描述是关于如何在MyBatis中正确地执行一个批量插入操作,其中一个字段的值依赖于对同一张表的SELECT查询结果。
Mybatis批量foreach merge into的用法
但是,如果数据量太大,可能会出现性能问题。Mybatis批量foreach merge into的用法可以批量插入时间价格表数据,但是需要注意其缺陷和限制。
mybatis+Oracle做批量导入时的坑
在Java开发中,MyBatis框架与Oracle数据库结合进行批量数据导入时,可能会遇到一些问题。本文将详细探讨这些问题,并提供一种可行的解决方案。
mybatis plus 5种批量操作性能测试
但需要注意线程安全问题,避免并发写入导致的数据一致性问题。4.


Web 开发
