批量更新或者新增

更新例子:

参数@param("list")

javascript 复制代码
<update id="对应方法">
<foreach collection="list" item="list" separator=";">
update 表名
set 参数A = #{list.参数A,jdbcType=类型}
where user_id = #{list.userId,jdbcType=VARCHAR} and discount_group_id=#{list.discountGroupId,jdbcType=VARCHAR}
</foreach>
</update>

新增:

javascript 复制代码
<insert id="insetList">
insert into uc_user_price_config (id, user_id, create_time,update_time, price, machine_id,status,processor_type) values
<foreach collection="list" item="item" separator=",">
(#{item.id}, #{item.userId}, #{item.createTime}, #{item.updateTime},#{item.price},#{item.machineId},#{item.status},#{item.processorType})
</foreach>
</insert>

数据库配置:

&allowMultiQueries=true

完整的:

spring.datasource.url =jdbc:mysql://10.23.100.70:3306/xneo?useAffectedRows=true&useUnicode=true&characterEncoding=UTF8&allowMultiQueries=true

相关推荐
ps酷教程3 小时前
Jackson 解决没有无参构造函数的反序列化问题
java
NiceCloud喜云3 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
ccddsdsdfsdf3 小时前
DBeaver怎么链接mongoDB
数据库·mongodb
_日拱一卒4 小时前
LeetCode:994腐烂的橘子
java·数据结构·算法·leetcode·深度优先
隔窗听雨眠4 小时前
Nginx网关响应慢排查手记
java·服务器·nginx
丷丩4 小时前
Postgresql基础实践教程(十一)各种Join
数据库·postgresql·join
星夜夏空994 小时前
FreeRTOS学习(4)——内存映射
数据库·学习·mongodb
智慧物业老杨4 小时前
智慧物业合同周期管理系统:从风险预警到智能交接的全流程数智化落地方案
java·人工智能·python
源码宝5 小时前
MES系统源码:Java8 + SpringBoot2.7 + MySQL8 + Redis,后端源码清爽易扩展
java·后端·源码·springboot·mes系统·源码二开·mes源码
TheRouter5 小时前
AI Agent 记忆体系建设实战:短期、长期与工作记忆的工程实现
数据库·人工智能·oracle