【ibatis】ibatis动态操作sql数据

来源:互联网 发布:网络暴力论文与人文 编辑:程序博客网 时间:2024/06/06 12:34
//简单的判断时候为空
<select id="selectProductAll" parameterClass="Batch" resultClass="Batch">  select t.proid as proid from t_hx_product_info t where 1=1  <isNotEmpty property="proviAccountid" >//如果传入过来的proviAccountid不为空             <isNotEqual prepend="and" property="proviAccountid" compareValue="0">//传入过来的proviAccountid不等于0               t.procompanyid=#proviAccountid#//如果以上的条件都满足,则根据传入过来的proviAccountid进行操作。             </isNotEqual>  </isNotEmpty>   </select>

//迭代条件查询
<select id="selectProxyByProvi" parameterClass="java.util.List" resultClass="Batch">select  from t_hx_person_safe_info ti,  (select t.accountid,t.CITYRLATION  from t_hx_user t where 1=1 and<iterate conjunction="," open="CITYRLATION in (" close=")">#list[].cityAccountid#</iterate>) ta//迭代条件where ti.seller = ta.accountid and  DATE_FORMAT(ti.signdate ,'%Y-%m-%d') between #list[0].satrtTime# and #list[0].endTime#</select>

<!-- 根据操作人用户名,匹配全部子用户,like操作批量删除, 传入List<accountid>数组,匹配多个 --><statement id="delPermissionByParentnames" parameterClass="java.util.List">DELETE FROM t_hx_permissions<iterate prepend="WHERE"  open="(" close=")" conjunction="OR">accountid like CONCAT('%',#[]#,'%')    //因为参数是一个list结合。#[]#表示循环中的实体</iterate></statement>