mybatis動態sql中的兩個內置參數(_parameter和_databaseId)
?<!--?mybatis動態sql的兩個內置參數
?? ??????? 不只是方法傳遞過來的參數可以被用來判斷,取值
?? ??? mybatis默認還有兩個內置參數
?? ????????_parameter:代表整個參數
?? ?????????????????????????????????? 單個參數:_parameter就是這個參數
?? ?????????????????????????????????? 多個參數:參數會被封裝為一個map:_parameter就是代表這個map??????????? ?
?? ??????? _databaseId:如果配置了databaseIdProvider標簽
?? ???????????? _databaseId 就是代表當前數據庫的別名mysql或者oracle等等。
?? ?? -->
?? ? ?
?? ? ?
?? ?? <!-- List<Employee> getEmpsTestInnerParameter(Employee?employee); -->
?? ?? <select id="getEmpsTestInnerParameter" resultType="com.hand.mybatis.bean.Employee">
?? ?????? SELECT * FROM emp?
?? ?????? <if test="_parameter!=null">??????_parameter相當于傳入的參數employee,判斷employee是否為空,若不為空則執行where條件?
?? ??????? where ename=#{_parameter.eName}???
?? ?????? </if>
?? ?? </select>
本文摘自 :https://blog.51cto.com/u