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语句跳出多重循环体 ...
随机推荐
- 【读书笔记】segment routing mpls数据平面-2
- 求$N^N$的首位数字
正如"大得多"定理所言,当$n\longrightarrow \infty$时: $$ n^n \gg n! \gg a^n \gg n^b \gg ln^kn $$ $f(n) = n^n$的增长 ...
- jquery遍历----end()方法
定义和用法 end() 方法结束当前链条中的最近的筛选操作,并将匹配元素集还原为之前的状态. 举个栗子: <body> <ul class="first"> ...
- WordCount编码实现及单元测试(第二次作业)
项目码云地址:https://gitee.com/zhujunlin/wc.git 一.题目思路 ========== 阅读完题目要求之后我很懵,因为之前从未使用过博客园和码云工具,对编程的目标需求也 ...
- 项目(八) Jenkins持续集成与构建
Jenkins环境搭建 由于Jenkins是依赖于java的,所以先介绍java环境的搭建 1)使用官方的二进制包解压安装,官方二进制包的下载地址:http://www.oracle.com/tech ...
- background-attachment: fixed 在iphone设备失效的解决
下面为引用,源代码有点问题,自己修改了一下.先做记录,回头再细修. 引用部分,但代码有问题 http://www.ptbird.cn/css-background-attachment--fiexed ...
- 监控服务器配置(五)-----Redis_exporter安装配置
1.下载redis_exporter安装包(linux版)到 /opt/minitor/redis_exporter . 下载地址:https://download.csdn.net/download ...
- 1、背景介绍及移动云MAS平台 --短信平台
目的: 刚开发完成一套短信平台以及一个Web端短信发送系统,短信平台耗时两个周.短信发送系统耗时两个多月,开发使用的技术没什么高科技含量,在此主要是记录下很多情况的处理方案,希望能让大家提出改善方案和 ...
- sed awk
sed -n 's/,*$//g;s/,\+/,/g;/,/p' test.csv 去除行尾逗号,将多个连续逗号合并,过滤没有逗号的行 awk -F, 'NF>5 split($1,a,&quo ...
- double team
队长博客链接 https://www.cnblogs.com/98-10-22-25/p/9806296.html 团队队名 泡面 团队成员 211606361 何承华(队长) 211606356 陈 ...