zoukankan      html  css  js  c++  java
  • mybatis动态sql之内置参数_parameter和_databaseId

    _parameter:代表整个参数

    • 单个参数:就是这个参数
    • 多个参数:参数会被封装成一个Map
    public List<Employee> getEmp(Employee employee);
    <select id="" result="">
        <if test="_databaseId='mysql'">
            select * from tbl_employee
            <if test="_parameter!=null">
                where last_name=#{_parameter.lastName}
            </if>
        </if>
    </select>

    上面的意思是如果传入的参数不是空,则根据last_name进行查询,此时的_parameter是一个Employee对象。


    _databaseId:如果在mybatis配置文件中配置了databaseIdProvider标签,_databaseid就代表当前数据库的别名。

    <databaseIdProvider type="DB_VENDER">
        <property name="MySql" VALUE="mysql"/>
        <property name="Oracle" VALUE="oracle"/>
        <property name="SQL Server" VALUE="sqlserver"/>
    </databaseIdProvider>

    使用时可以这么使用:

    <select id="" result="">
        <if test="_databaseId='mysql'">
            select * from tbl_employee
        </if>
        <if test="_databaseId='oracle'">
            select * from employee
        </if>
    </select>
  • 相关阅读:
    目标检测:YOLOV2
    目标检测:YOLOV1
    格拉姆矩阵(Gram matrix)详细解读
    Java 线程Thread.Sleep详解
    luogu2429 制杖题
    luogu2441 角色属性树
    luogu2398 SUM GCD
    luogu2303 [SDOI2012] Longge的问题
    luogu2054 洗牌 同余方程
    线性同余方程
  • 原文地址:https://www.cnblogs.com/xiximayou/p/12227162.html
Copyright © 2011-2022 走看看