// Model: Test.java
@Data
public class Test {
private String x;
private String y;
private String z;
}
// Mapper: TestMapper.java
public void insertTestList(List<Test> testList);
<!-- XML: TestMapper.XML -->
...
<!-- 忽略重复数据 -->
<insert id="insertTestList" parameterType="Test">
INSERT IGNORE INTO
test_table(test_x, test_y, test_z)
VALUES
<foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
#{item}.x, #{item.y}, #{item}.z
</foreach>
</insert>
<!-- 更新重复数据 -->
<insert id="insertTestList" parameterType="Test">
INSERT INTO
test_table(test_x, test_y, test_z)
VALUES
<foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
#{item}.x, #{item.y}, #{item}.z
</foreach>
ON DUPLICATE KEY UPDATE
test_x = VALUES(test_x),
test_y = VALUES(test_y),
test_z = VALUES(test_z)
</insert>
...
insert into test_table(x, y, z) values (1, 1, 1), (2, 2, 2), (3, 3, 3)
// Model: Test.java
@Data
public class Test {
private String x;
private String y;
private String z;
}
// Mapper: TestMapper.java
public void deleteTestList(List<Test> testList);
<!-- XML: TestMapper.XML -->
...
<delete id="deleteTestList" parameterType="Test">
DELETE FROM
test_table
WHERE
<foreach item="item" index="index" collection="list" open="(" close=")" separator="OR">
test_x = #{item.x} AND test_y = #{item.y} AND test_z = #{item.z}
</foreach>
</delete>
...
delete from test_table where (test_x = 1 AND test_y = 1 AND test_z = 1) or (test_x = 2 AND test_y = 2 AND test_z = 2) or (test_x = 3 AND test_y = 3 AND test_z = 3)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有