mybatis动态sql传ist集合參与传数组参数

                                        动态sql传集合參

传list集合:

传list集合
SQL:
<select id="queryDeptListByBankLevelAndBankName" parameterType="java.util.HashMap"
			resultMap="queryDeptListByBankLevelAndBankNameResult">
		select DEPTSEQ ,
		DEPTNAME,DEPTID
		from DEPT
		 WHERE 1=1
		<if test="DeptLevel != null and DeptLevel != ''">And DeptLevel=#{DeptLevel}</if>
		<if test="DeptName != null and DeptName != ''"> and DeptName LIKE '%' || #{DeptName} || '%'</if>
		<if test="DeptSeq != null and DeptSeq != ''"> and DeptSeq=#{DeptSeq}</if>
		<if test="deptIdList != null and deptIdList.size > 0 ">
		 and DEPTID not in
		 <foreach collection="deptIdList" item ="deptId" index="i" open="(" close=")" separator=",">
		           #{deptId}
		 </foreach>
		 </if>
		 ORDER BY DEPTID
	</select>

接口:
		ArrayList deptIdList = new ArrayList();
        	String [] deptIds = {"006001", "006002", "006003", "006004", "006005", "006006", "006007",
        	        "006008", "006009", "006010", "006011", "006012", "006013", "006015",
        	        "006016", "006017", "006018", "006019", "006020", "006021", "006022",
        	        "006023", "006024", "006025", "006026", "006027", "006028", "006029",
        	        "006030", "006031", "006032", "006033", "006034", "006035", "006036",
        	        "006037", "006038", "006039", "006040", "006041", "006042", "006043",
        	        "006044", "006045", "006501", "009801", "009802", "009803", "009809",
        	        "009810", "009811", "014001", "015001", "016001", "016501", "019801",
        	        "019802", "019803", "019804", "019805", "019806", "026501", "027006",
        	        "027106", "027206", "027306", "027406", "027506", "029801", "036501",
        	        "037006", "039801", "046501", "047006", "049801", "056501", "057006",
        	        "809801", "059801", "066501", "067006", "069801", "076501", "077006",
        	        "079801", "086501", "087006", "089801", "097006", "099801", "107006",
        	        "109801", "117006", "117106", "119801", "127006", "129801", "806501",
        	        "809801", "816501", "819801", "9802"};
        	Collections.addAll(deptIdList, deptIds);
        	Map map = new HashMap();
        	map.put("deptIdList",deptIdList);
        	subList = this.sqlMap.queryForList("mcmmcif.queryDeptListByBankLevelAndBankName", map);	 

传数组:

	传数组:
SQL:
		<select id="queryDeptListByBankLevelAndBankName" parameterType="java.util.HashMap"
			resultMap="queryDeptListByBankLevelAndBankNameResult">
		select DEPTSEQ ,
		DEPTNAME,DEPTID
		from DEPT
		 WHERE 1=1
		<if test="DeptLevel != null and DeptLevel != ''">And DeptLevel=#{DeptLevel}</if>
		<if test="DeptName != null and DeptName != ''"> and DeptName LIKE '%' || #{DeptName} || '%'</if>
		<if test="DeptSeq != null and DeptSeq != ''"> and DeptSeq=#{DeptSeq}</if>
		<if test="deptIdList != null and deptIdList.length > 0 ">
		 and DEPTID  in
		 <foreach collection="deptIdList" item ="deptId" index="i" open="(" close=")" separator=",">
		           #{deptId}
		 </foreach>
		 </if>
		 ORDER BY DEPTID
	</select>

接口:
	
	String [] deptIds = {"006007","006010","006011","006024","006025","006034","006035","006037",
        			"016501","016601","016701","016801","016901","017001","017101","017201","017301","017401",
        			"017501","017601","017605","017701","017801","017901","018001","018101","018301","018401",
        			"018501","018601","018701","018801","018901","019001","019101","019201","019301","019401",
        			"019501","019802","019803","019804","019805","019806","026501","027001","027101","027201",
        			"027301","027401","027501","037001","047001","047002","057001","067001","077001","087001",
        			"097001","107001","117001","117101","127001","800101","800102","800103","810101","810102",
        			"810103"};
        	Map map = new HashMap();
        	map.put("deptIds",deptIds);
        	subList = this.sqlMap.queryForList("mcmmcif.queryDeptListByBankLevelAndBankName", map);

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_无往而不胜_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值