• 當前位置:首頁 > IT技術 > 數據庫 > 正文

    mybatis動態sql中的兩個內置參數(_parameter和_databaseId)
    2021-10-11 14:56:22

    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

    開通會員,享受整站包年服務
    国产呦精品一区二区三区网站|久久www免费人咸|精品无码人妻一区二区|久99久热只有精品国产15|中文字幕亚洲无线码