MyBatis_1 xml常用

//特點
mybatis  方法不能重載
//xml常用
原符號       <        <=        >        >=        &         '           "
替換符號    &lt;     &lt;=     &gt;     &gt;=     &amp;     &apos;     &quot;
<![CDATA[ >= ]]>
<![CDATA[ <= ]]>
<![CDATA[ > ]]>
<![CDATA[ < ]]>
1長度
<if test="orgCode.length() == 1"></if>
2相等
<if test='taskDefKey.equals("AAA")'></if>
3字符相等 即最外邊用雙引號,裏邊用單引號,此寫法會報java.lang.NumberFormatException
<if test="stringParam != null and stringParam != 'a'"></if>
4判斷存在
<if test="stringParam.indexOf('aa') != -1"></if>
5判斷Integer是否大於0 gt大於,lt小於
<if test="idParam !=null and idParam gt 0"></if>
6like
<if test="title != null">
     AND  title LIKE CONCAT('%',#{boatName},'%')
</if>
7時間區間
<if test="warnBeginTime!=null ">
    and DATE_FORMAT(w.WARN_BEGIN_TIME, '%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]>   DATE_FORMAT(#{warnBeginTime},
    '%Y-%m-%d %H:%i:%s')
</if>
8.list>0
<if test="list.size() > 0">
9多條件判斷
<choose>
    <when test="sameEmailList != null and sameEmailList.size > 0 ">
    </when>
    <when test="">
    </when>
    <otherwise>
    </otherwise>
</choose>

//只有自增纔會返回主鍵,其他id不需要返回主鍵
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
    SELECT LAST_INSERT_ID()
</selectKey>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章