ibatis批量操作  这文章的补充吧。

review代码的时候发现一个页面应用排序设置功能,原先代码中,进行了循环update实现。虽然应用较少,不过无谓浪费数据库链接实在不是一个好的想法。

所以,我觉得应该杜绝循环中的任何数据可操作才能避免很多地雷的埋下。

修改后:

批量更新语句的写法,基于ibatis,只使用iterate  标签:

    <update id="batchUpdateShowOrder" parameterClass="map">
update wi_open_app_sub_new set gmtModified=NOW() , showOrder =
<iterate property="apps" open="case" close="end" >
when appId=#apps[].appId# then #apps[].showOrder#
</iterate>
where merchantId=#merchantId# and appId in
<iterate property="appIds" open="(" close=")" conjunction=",">
#appIds[]#
</iterate>
</update>

实现sql语句:

update wi_open_app_sub_new set
showOrder = case when appid =10199 then 1 when appid =4 then 2 when appid =3 then 3 when appid =10134 then 4 when appid=1 then 5 when appid=5 then 6 end
where
merchantid='8a22b1864b498152014b498246610001' and appid in( 10199, 4, 3 , 10134, 1, 5 );

ibatis批量操作补充的更多相关文章

  1. 【ibatis】IBatis的SQL批量操作

    1.Ibatis批量添加(传入class的list即可) <insert id="Add" resultMap="Select" parameterCla ...

  2. Hibernate和IBatis对比

    [转自]http://blog.csdn.net/ya2dan/article/details/7396598 项目也做过几个, 使用IBatis就做一个项目, 基本上都是使用Hibernate, 也 ...

  3. MyBatis的几种批量操作

    MyBatis中批量插入 方法一: <insert id="insertbatch" parameterType="java.util.List"> ...

  4. java面试总结-(hibernate ibatis struts2 spring)

    说说Hibernate对象的三种状态 Hibernate对象有三种状态,分别是:临时态(Transient). 持久态(Persistent).游离态(Detached). 临时状态:是指从对象通过n ...

  5. Spring + iBatis 的多库横向切分简易解决思路

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  6. mybatis和ibatis区别

     ibatis本是apache的一个开源项目,2010年这个项目由apache software foundation 迁移到了google code,并且改名为mybatis.  1.Mybat ...

  7. Struts2+Spring+Ibatis集成合并

    上一篇博客讲述了Struts2+Spring的集成合并,主要是利用了一个中间jar包,这篇博客在加上Ibatis持久层框架,三个框架进行合并.其中Struts2和Spring部分和前边的一样,主要是讲 ...

  8. Ibatis之3个不经常使用的Query方法

    1.queryForObject /** * Executes a mapped SQL SELECT statement that returns data to populate * the su ...

  9. Ibatis教程

    Ibatis教程 |字号     转自:http://blog.csdn.net/lhminjava/article/details/1871136 ibatis 开发指南ibatis Quick S ...

随机推荐

  1. 从零开始学iPhone开发(2)——控件的使用

    这一节我们开始学习iOS中简单控件的使用. 在iOS编程中,简单的控件有很多,其中主要的用的多的有: UILabel,UIButton,UISegmentedControl, UITextField, ...

  2. GZFramwork快速开发框架演练之会员系统(四)添加商品管理

    1.1:创建表结构 新建三张商品关联的表,表模型如下: 创建SQL语句略 1.2:生成表Model(生成方法见上一节) 1.3:生成tb_ProductType的单结构界面然后添加到项目中 1.4:修 ...

  3. IE6兼容性问题及IE6常见bug详细汇总

    转载地址:http://www.jb51.net/css/76894.html 1.IE6怪异解析之padding与border算入宽高 原因:未加文档声明造成非盒模型解析 解决方法:加入文档声明&l ...

  4. <hr/> 水平线样式

    <hr style="width:490px;" /> <hr size=8 style="COLOR: #ffd306;border-style:ou ...

  5. Servlet 实现上传文件以及同时,写入xml格式文件和上传

    package com.isoftstone.eply.servlet; import java.io.BufferedReader; import java.io.BufferedWriter; i ...

  6. shiro的Helloworld

    package shiro; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePassword ...

  7. Filestream(读写)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  8. 浏览器html页面乱码问题分析

    直接访问某html文件,浏览器显示编码是正常的,页面通过<meta charset="UTF-8">指定了编码方式,该文件存储编码也是utf8. 通过配置的org.sp ...

  9. python中lambda表达式应用

    对于简单的函数,也存在一种简便的表示方式,即:lambda表达式 #普通函数1 def func(a): return a+1 print 'test1_func0:',func(1000)4#lam ...

  10. 怎么获取iOS的私有API

    前言 作为iOS开发人员,相信大多数伙伴都对怎么获取iOS的私有API很有兴趣,最近通过查找资料,总结了以下三种方法,希望对你有用. 第一种(class-dump) 不得不说这是一个很棒的工具,安装和 ...