Mybatis 动态SQL语句foreach
来源:互联网 发布:最心酸的一句话知乎 编辑:程序博客网 时间:2024/06/07 04:55
foreach:包含以下属性:
- collection :传递过来的参数名字。
- item,变量名字,collection 中的一个对象。当传递的是map时,item代表value.
- index,索引名字,当迭代map时,为key值。
- open:开头的字符串。
- close:结尾的字符串。
- separator 每次循环的分隔符。
对于list
int insertList(@Param("liu") List<SysUser> users); <insert id="insertList"> insert into sys_user(user_name,user_password,user_email,user_info) values <!-- liu 默认值为list item 自由定义指collection 中的对象,foreach中的数据为一次,多次使用separator处理--> <foreach collection="liu" item="user" separator=","> ( #{user.userName},#{user.userPassword},#{user.userEmail},#{user.userInfo} ) </foreach> </insert>
对于 map
int updateByMap(@Param("collection1") Map<String ,Object> map); <!-- collection1 为传递过来的值,默认值为_parameter,item代表value,index 代表key--> <update id="updateByMap"> update sys_user set <foreach collection="collection1" item="liu" index="yang" separator=","> ${yang} = #{liu} </foreach> where id = #{collection1.id} </update>
阅读全文
0 0
- Mybatis 动态SQL语句foreach
- MyBatis动态sql详解(二) foreach语句详解
- MyBatis的动态sql语句详解,foreach等
- mybatis 动态sql之foreach
- mybatis动态SQL语句
- mybatis动态SQL语句
- mybatis动态SQL语句
- MyBatis 动态SQL语句
- mybatis 动态SQL语句
- mybatis 动态sql语句
- mybatis动态SQL语句
- Mybatis 动态SQL语句
- mybatis动态sql语句
- MyBatis动态SQL语句
- Mybatis动态sql语句
- mybatis动态SQL语句
- mybatis 动态SQL语句
- mybatis动态SQL语句
- 使用自带Zookeeper搭建kafka集群
- mysql数据类型及长度全解
- python中的element elements
- netty源码分析(十八)Netty底层架构系统总结与应用实践
- UML类图与类的关系详解
- Mybatis 动态SQL语句foreach
- Android ViewHolder 生成工具(帮助生成findviewbyid)
- 数据结构--链栈的实现
- android查看大包时的keystore文件
- vmvare下centos网络连接nat模式 虚拟机与主机ping不同
- android 游戏移植 (一) (文末有福利) | SDL 西游释厄传调试
- 逻辑回归总结
- 学web前端如何下手
- 如何选择优化器 optimizer