zoukankan      html  css  js  c++  java
  • mybatis中的mapxml的语法

    <select id="a" resultMap="map">
    select
    *
    from `table`
    where (po_type='1')
    and t2.dn_id in
    <foreach item="item" index="index" collection="si_dn_ids" open="(" separator="," close=")">
    #{item}
    </foreach>
    <choose>
    <when test="poNo != null and poNo !='' ">
    `po_no`=#{poNo}
    </when>
    <otherwise>
    <![CDATA[
    `create_time` >= #{startTime} and `create_time` < #{endTime}
    ]]>
    <if test="status != 0">
    and `status`=#{status}
    </if>
    <if test="pager != null">
    limit #{pager.start},#{pager.pageSize}
    </if>
    </otherwise>
    </choose>
    </select>

    其中,foreach元素的属性主要有 item,index,collection,open,separator,close。item表示集合中每一个元素进行迭代时的别名,即为list中的每个元素,可以是String等类型,也可以是bean(如果直接传的bean,需要拼接bean的某个属性的值,可以写为#{item.property} ),index指定一个名字,用于表示在迭代过程中,每次迭代到的位置,open表示该语句以什么开始,separator表示在每次进行迭代之间以什么符号作为分隔 符,close表示以什么结束。

    更多动态sql语法参见:http://blog.csdn.net/luqin1988/article/details/7831927

  • 相关阅读:
    C++ | Int转十六进制字符串
    Qt | QML Image SSL handshake failed
    《大话数据结构》第一章 数据结构绪论
    8组Beta冲刺4/5
    8组Beta冲刺1/5
    8组Beta冲刺3/5
    8组Beta冲刺2/5
    8组Beta冲刺5/5
    软工实践个人总结
    8组Beta冲刺总结
  • 原文地址:https://www.cnblogs.com/superJF/p/4994785.html
Copyright © 2011-2022 走看看