当前位置: 首页 > news >正文

西安俄语网站建设怎么把网站做成软件

西安俄语网站建设,怎么把网站做成软件,抖音开放平台工会,爱用建站怎么样今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了 批量…

今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了

批量插入(传入的参数是List<实体>list):

<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="java.util.List">insert into xhs_collection_data (note_id,`status`,title,`desc`,`time`,user_id,nickname,liked_count,collected_count,comment_count,share_count,image_list,tag_list,batch_number,file_name) values<foreach collection="list" separator="," item="item">( #{item.noteId,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER},#{item.title,jdbcType=VARCHAR},#{item.desc,jdbcType=VARCHAR},#{item.time,jdbcType=TIMESTAMP},#{item.userId,jdbcType=VARCHAR}, #{item.nickname,jdbcType=VARCHAR},#{item.likedCount,jdbcType=VARCHAR},#{item.collectedCount,jdbcType=VARCHAR},#{item.commentCount,jdbcType=TIMESTAMP},#{item.shareCount,jdbcType=VARCHAR},#{item.imageList,jdbcType=VARCHAR},#{item.tagList,jdbcType=VARCHAR},#{item.batchNumber,jdbcType=BIGINT},#{item.fileName,jdbcType=VARCHAR})</foreach>
</insert>



批量修改(传入的参数是List<实体>list):

sql原理语句:update table set 要修改的表字段A = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end,
要修改的表字段B = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end where 条件

注意:这里踩过一个坑,因为当时不会写批量修改的语句,所以让文心一言帮忙生成了一个批量修改的sql,后续我忘记是不是手动给<foreach>标签手动加的<separator=“,”>这个属性,结果报错了,排查了半天这个sql哪里错了,最后还是放到数据库执行了一下看到了错误原因,当时我还让温馨一样帮忙检查了下我修改后的sql,结果还说没sql没问题,只是可能在拼接时报错

<update id="updateList" parameterType="java.util.List">update xhs_collection_data<trim prefix="set" suffixOverrides=","><trim prefix="`status` = case" suffix="end,"><foreach collection="list" index="index" item="item" >when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.status,jdbcType=INTEGER}</foreach></trim><trim prefix="title = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.title,jdbcType=VARCHAR}</foreach></trim><trim prefix="`desc` = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.desc,jdbcType=VARCHAR}</foreach></trim><trim prefix="time = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.time,jdbcType=TIMESTAMP}</foreach></trim><trim prefix="user_id = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.userId,jdbcType=VARCHAR}</foreach></trim><trim prefix="nickname = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.nickname,jdbcType=VARCHAR}</foreach></trim><trim prefix="liked_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.likedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="collected_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.collectedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="comment_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.commentCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="share_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.shareCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="image_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.imageList,jdbcType=VARCHAR}</foreach></trim><trim prefix="tag_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.tagList,jdbcType=VARCHAR}</foreach></trim><trim prefix="batch_number = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.batchNumber != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.batchNumber,jdbcType=BIGINT}</if></foreach></trim><trim prefix="file_name = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.fileName != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.fileName,jdbcType=VARCHAR}</if></foreach></trim></trim>where note_id in<foreach close=")" collection="list" item="item" open="(" separator=", ">#{item.noteId,jdbcType=VARCHAR}</foreach>
</update>
http://www.yayakq.cn/news/646557/

相关文章:

  • 内蒙古企业网站建设深圳龙华医院网站建设
  • 有什么公司做网站好站长查询
  • 杭州精品网站建设网络推广的基本方法有哪些
  • 招标网站排名wordpress作者 页面
  • 网站开发招标前提网站单页在线制作软件
  • 商城网站是怎么做的如何做资源论坛网站
  • 建筑公司网站模板网站空间域名能不能自己续费
  • 网站后台可视化编辑网站建设的人性分析
  • 网站定制要求2022百度指数排名
  • 互联网网站建设月总结招聘网站策划书
  • 高端品牌网站建设优势网页优化方法
  • 代运营网站建设简洁个人博客网站模板
  • 携程的网站建设项目规划书网络推广专员考核指标
  • 东莞p2p网站开发费用seo超级外链工具
  • wordpress网站扫描工具景安建网站
  • 字牌标识公司网站网站编号 6019岳阳市网页设计人才网
  • 平台与网站有什么区别wordpress 自定义字段插件
  • 南昌做网站的公司上海的网站建设
  • 网站开发制做网站做签到功能
  • 郑州网站建设推销wordpress主页不显示文章
  • 玉溪做网站公司天津做网站建设
  • 做特效很牛的一个外国网站贵阳网站建设公司招聘
  • 抢先注册网站域名卖掉仿网站后台怎么做
  • 娱乐网站怎么制作织梦做的网站页面打不开
  • 网站建设 会议主持稿wordpress 幻灯片代码在哪里
  • 文化传播公司网站模板住房城乡建设部服务平台
  • 建网站用自己的主机做服务器寿县网站建设
  • 腾讯风铃怎么做网站霸州市建设局网站
  • 做网站维护要什么专业龙岩网站建设方式
  • 百度公司网站制作wordpress建站腾讯云