在网上搜索mybatis批量增加数据的方法,以及主键自动生成的方法,大多数基本都是自增批量插入的,不是用的uuid,我找了半个小时都没找到批量增加uuid的方法,然后就灵光一闪,这样写:

 
<insert id="createUserList" parameterType="java.util.List" > INSERT into
sys_user( id, username, password, phone, create_date )VALUES <foreach
collection="list" item="item" index="index" separator="," > ( (SELECT
REPLACE(UUID(), '-', '') AS id), #{item.username}, #{item.password},
#{item.phone}, now() ) </foreach> </insert>
 

把(SELECT REPLACE(UUID(), '-', '') AS id)  引入进来,ok!!!

 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信