iBtais 多重嵌套循环
iBatis支持集合循环, 但是如何做到双重循环, 请见下例子
例子描述:
需要去三张结构相同的表中获取信息, 需要将信息拼合去重后返回
入参数据类型: Map<String,Object>, regions = List<OrderRegionNum>
class OrderRegionNums{
String regionSchema
String regionCode
List<Integer> orderNums
}
注意的是在标签中的property属性中使用时:不需要加 $或者# 直接regions[].orderNums
<select id="selectOrderNumListByRegionCodeByListOrderNum" resultMap="orderNumInfo" parameterClass="java.util.HashMap">
<dynamic>
<iterate property="regions" conjunction="UNION">
select distinct(r.ID),r.ORD_NR,r.ORD_RGN_CD
from $regions[].regionSchema$.table
where
r.EXCH_SRVCR_QT > 0
and r.ORD_RGN_CD = #regions[].regionCode#
and r.ORD_NR in
<iterate property="regions[].orderNums" open="(" close=")" conjunction="," >
#regions[].orderNums[]#
</iterate>
</iterate>
</dynamic>
</select>
----------------------------------------------------------------------------------------------------------------------
<isNotEmpty prepend="and" property="marketShopAuthFlatAreaDtos">
<iterate property="marketShopAuthFlatAreaDtos" conjunction="or">
project_id in
<iterate conjunction=',' property="marketShopAuthFlatAreaDtos[].projectIds" open="(" close=")">
#marketShopAuthFlatAreaDtos[].projectIds[]#</iterate>
AND
(
1!=1
<isNotEmpty prepend="or" property="marketShopAuthFlatAreaDtos[].provinceNodes" >
shop_address_province in
<iterate conjunction=',' property="marketShopAuthFlatAreaDtos[].provinceNodes" open="(" close=")">
#marketShopAuthFlatAreaDtos[].provinceNodes[].nodeCode#</iterate> </isNotEmpty>
<isNotEmpty prepend="or" property="marketShopAuthFlatAreaDtos[].cityNodes">
shop_address_city in
<iterate conjunction=',' property="marketShopAuthFlatAreaDtos[].cityNodes" open="(" close=")">
#marketShopAuthFlatAreaDtos[].cityNodes[].nodeCode#</iterate> </isNotEmpty> <isNotEmpty prepend="or" property="marketShopAuthFlatAreaDtos[].countyNodes"> shop_address_country in
<iterate conjunction=',' property="marketShopAuthFlatAreaDtos[].countyNodes" open="(" close=")">
#marketShopAuthFlatAreaDtos[].countyNodes[].nodeCode#</iterate> </isNotEmpty>
<isNotEmpty prepend="or" property="marketShopAuthFlatAreaDtos[].townNodes"> shop_address_street in
<iterate conjunction=',' property="marketShopAuthFlatAreaDtos[].townNodes" open="(" close=")">
#marketShopAuthFlatAreaDtos[].townNodes[].nodeCode#</iterate> </isNotEmpty>
)
</iterate> </isNotEmpty>
------------------------------------------------------------------------------------------------------------
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
iBtais 多重嵌套循环的更多相关文章
- java如何跳出多重嵌套循环
Java里的break能跳出循环但是只能跳出一个,goto这个在java中也只是被当作关键是,没有任何作用 要做到跳出多重嵌套循环,可以用此方法 在循环体开头设置一个标志位,设置一个标记,然后使用带此 ...
- ThinkPHP学习 volist标签高级应用之多重嵌套循环、隔行变色(转)
Action代码: public function index(){ $prod = I("get.prod_en"); $id = I("get.id", 0 ...
- 【笔试题】在 Java 中,如何跳出当前的多重嵌套循环?
笔试题 在 Java 中,如何跳出当前的多重嵌套循环? public class Demo { public static void main(String[] args) { System.out. ...
- 如何在java中跳出当前多重嵌套循环?有几种方法?
如何在java中跳出当前多重嵌套循环?有几种方法? - 两种方法 - 1.在外层循环定义标记 ok: for(int i=0;i<100;i++){ ...
- Java中如何指定跳出多重嵌套循环
今天做项目优化涉及到一个跳出指定多重嵌套循环的问题,觉得还是记录一下那么在Java中如何跳出当前的多重嵌套循环? 方法一:可以在需要的循环语句前定义一个标号,然后在里层循环体的代码中使用带有标号的br ...
- java基础面试题:java中有没有goto? 在JAVA中如何跳出当前的多重嵌套循环?
goto是Java的保留关键字,但是从来没有直接使用到goto,goto的跳转作用在Java中受到了限制,只有在特定场合下才能使用,如while for等循环中用continue.break或结合标签 ...
- 在JAVA中怎样跳出当前的多重嵌套循环?
在JAVA中怎样跳出当前的多重嵌套循环? 这道题是考察大家对于break语句的应用.同一时候也是对你多重嵌套循环的使用进行考察.在java中,要想跳出多重循环,能够在外循环语句前面定义 ...
- Java中跳出多重嵌套循环的方法
一.使用标号 1.多重嵌套循环前定义一个标号 2.里层循环的代码中使用带有标号 break 的语句 public static void main(String[] args) { ok: for(i ...
- java跳出多重嵌套循环
public class BreaklFor { public static void main(String args[]){ OK: //设置一个标记 使用带此标记的break语句跳出多重循环体 ...
随机推荐
- (译)MySQL的10个基本性能技巧
原文出处:https://www.infoworld.com/article/3210905/sql/10-essential-performance-tips-for-mysql.html MySQ ...
- git 新建仓库
rm -rf .git git init git add . git commit -m "Initial commit" git remote add origin <gi ...
- java.lang.OutOfMemoryError:GC overhead limit exceeded解决方法
异常如下:Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded 一.解 ...
- 小乌龟 coding 克隆、提交一直提示无权限
因为之前设置过账号,但是网上各种命令行清除都没有用,进入小乌龟设置删除全局配置,系统配置,保存就可以克隆等操作了
- win7安装oracle 10g问题总结。
1.安装oracle10g的时候,出现此问题,如图: 右键安装程序(setup.exe) -> 属性 -> 兼容性 -> 以兼容模式运行这个程序 windows xp( servi ...
- 执行多条SQL语句,实现数据库事务(不可传入Sql参数)
执行多条SQL语句,实现数据库事务(不可传入Sql参数) http://blog.csdn.net/hanxuemin12345/article/details/9980371
- 第八周博客作业 <西北师范大学| 周安伟>
第八周博客作业 助教博客链接https://home.cnblogs.com/u/zaw-315/ 作业要求博客链接https://www.cnblogs.com/nwnu-daizh/p/10687 ...
- 转)Ubuntu安装teamviewer
以下内容提炼于:https://www.cnblogs.com/wmr95/p/7574615.html 官网下载相应包:https://www.teamviewer.com/zhcn/downloa ...
- Wordpress 后台更改网址
在 `wp_options` 数据库执行下面两条命令 ```sql update wp_options set option_value = 'your_new_url' where option_n ...
- IDEA配置
关于IDEA的配置 配置注释模板 CTRL_SHIFT_S,在Live Templates中新增一个TemplateGroup,然后再新建两个模板,如下图: 新增cc-ClassComment /** ...