首页 > 代码库 > ibatis dynamic标签 的使用
ibatis dynamic标签 的使用
<!-- 根据给定的参数查询出对应的对账日志记录 --> <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标签 的使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。