码迷,mamicode.com
首页 > 其他好文 > 详细

ibatis dynamic标签 的使用

时间:2014-11-06 12:36:02      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   使用   java   sp   div   on   

<!-- 根据给定的参数查询出对应的对账日志记录 -->
    <select id="listByParamMap" parameterClass="java.util.Map" resultClass="AccCheckLog">
        select rl.ID as id,
               rl.STAFF_ID as staffId,
               rl.STAFF_NAME as staffName,
               rl.STAFF_PHONE_NUM as staffPhoneNum,
               rl.ORDER_ID as orderId,
               rl.AWARD_DATE as awardDate,
               rl.PAY_AMOUNT as payAmount,
               rl.ISSUER_ID as issuerId,
               rl.APPFROM as appfrom,
               rl.ISSUER_NAME as issuerName,
               rl.LOG_TIME as logTime,
               rl.TYPE as type,
               rl.COMMENTS as comments,
               rl.CHECK_RESULT_CODE as checkResultCode
          from INFO_AWARD_COUPON_RECORD_LOG rl
          <dynamic prepend="where">
                <isNotNull property="appfrom" prepend="and">
                        rl.APPFROM = #appfrom#
                </isNotNull>
                <isNotNull property="staffId" prepend="and">
                        rl.STAFF_ID = #staffId#
                </isNotNull>
                <isNotNull property="orderId" prepend="and">
                        rl.ORDER_ID = #orderId#
                </isNotNull>
                <isNotNull property="logTimeStart" prepend="and">
                        <![CDATA[rl.LOG_TIME >= to_date(#logTimeStart#,‘yyyymmdd‘)]]>
                </isNotNull>
                <isNotNull property="logTimeEnd" prepend="and">
                        <![CDATA[rl.LOG_TIME <= to_date(#logTimeEnd#,‘yyyymmdd‘)]]>
                </isNotNull>
                <isNotNull property="checkResultCode" prepend="and">
                        rl.CHECK_RESULT_CODE = #checkResultCode#
                </isNotNull>
                <isNotNull property="checkResultCodeNEq1" prepend="and">
                        rl.CHECK_RESULT_CODE != #checkResultCodeNEq1#
                </isNotNull>
          </dynamic>
    </select>

dynamic的prepend只要检测到第一个为“真”的条件比较元素(isNotNull标签),则覆盖其prepend属性并组装where关键字为动态SQL的一部分.

 

ibatis dynamic标签 的使用

标签:style   blog   color   ar   使用   java   sp   div   on   

原文地址:http://www.cnblogs.com/mqyg/p/4078310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!