Mybatis 批量insert
2015-11-27 11:53
232 查看
<insert id="insert" parameterType="ArrayList">
insert into XXX(id,name,type)
<foreach collection="list" item="item" index="index" separator="union all">
select #{item.id,jdbcType=INTEGER},#{item.name,jdbcType=VARCHAR},#{item.type,jdbcType=INTEGER} from dual
</foreach>
</insert>
dao:
public Integer insert(List<User> list){
return sqlSession.insert("userMapper.insert",list);
}
insert into XXX(id,name,type)
<foreach collection="list" item="item" index="index" separator="union all">
select #{item.id,jdbcType=INTEGER},#{item.name,jdbcType=VARCHAR},#{item.type,jdbcType=INTEGER} from dual
</foreach>
</insert>
dao:
public Integer insert(List<User> list){
return sqlSession.insert("userMapper.insert",list);
}
相关文章推荐
- Android之WebRTC介绍
- ArcGIS教程:欧氏距离 (空间分析)
- swift学习记录04-杂记
- MYSQL数据库的索引(index)
- js弹出框、对话框、提示框、弹窗总结
- ViewPager+Fragment滑动界面,并做延迟加载【终极解决】
- 正则表达式,grep、sed、awk命令
- android Google Map获取地理位置信息的方法
- 10004---Linux MySQL主从复制(Replication)配置
- Color the fence
- java中的数学计算函数
- android插件话和hotfix
- 10003---理解MySQL——复制(Replication)
- C#Chart属性
- windows ipc 相关练习
- DataTable中的数据赋值给model z
- dex分包变形记
- Hadoop core-site.xml 配置项列表
- erlang lists 系列函数功能
- jquery 显示“加载状态 结束”