XML
批量插入数据int insertStudentList(List<SysStudent> sysStudent);
<insert id="insertStudentList">
insert into sys_student(sut_id, stu_name, stu_year) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.sutId},#{item.stuName},#{item.stuYear})
</foreach>
</insert>
public interface SysStudentMapper extends Mapper<SysStudent> {
public String tableName = "sys_student";
public String columnNoId = "sut_id,stu_name,stu_year,;
@Insert("<script> " +
"insert into " + tableName +
"(" + columnNoId + ") " +
"values " +
"<foreach collection=\"items\" index=\"index\" item=\"item\" separator=\",\"> "
+
"(#{item.sutId},#{item.stuName},#{item.stuYear})"
+
"</foreach> " +
"</script>")
int batchSave(@Param("items") List<SysStudent> items);
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://code100.blog.csdn.net/article/details/123010393
内容来源于网络,如有侵权,请联系作者删除!