• mybatis list array参数


    <!--List:forech中的collection属性类型是List,collection的值必须是:list,item的值可以随意,Dao接口中参数名字随意 -->
        <select id="getEmployeesListParams" resultType="Employees">
            select *
            from EMPLOYEES e
            where e.EMPLOYEE_ID in
            <foreach collection="list" item="employeeId" index="index"
                open="(" close=")" separator=",">
                #{employeeId}
            </foreach>
        </select>

        <!--Array:forech中的collection属性类型是array,collection的值必须是:list,item的值可以随意,Dao接口中参数名字随意 -->
        <select id="getEmployeesArrayParams" resultType="Employees">
            select *
            from EMPLOYEES e
            where e.EMPLOYEE_ID in
            <foreach collection="array" item="employeeId" index="index"
                open="(" close=")" separator=",">
                #{employeeId}
            </foreach>
        </select>

        <!--Map:不单单forech中的collection属性是map.key,其它所有属性都是map.key,比如下面的departmentId -->
        <select id="getEmployeesMapParams" resultType="Employees">
            select *
            from EMPLOYEES e
            <where>
                <if test="departmentId!=null and departmentId!=''">
                    e.DEPARTMENT_ID=#{departmentId}
                </if>
                <if test="employeeIdsArray!=null and employeeIdsArray.length!=0">
                    AND e.EMPLOYEE_ID in
                    <foreach collection="employeeIdsArray" item="employeeId"
                        index="index" open="(" close=")" separator=",">
                        #{employeeId}
                    </foreach>
                </if>
            </where>
        </select>

    Mapper类:
    public interface EmployeesMapper { 

        List<Employees> getEmployeesListParams(List<String> employeeIds);

        List<Employees> getEmployeesArrayParams(String[] employeeIds);

        List<Employees> getEmployeesMapParams(Map<String,Object> params);
    }

  • 相关阅读:
    目录或文件被损坏且无法读取怎么办
    mvn前端node版本工具操作手册
    经典算法思想1——动态规划( Dynamic Programming)
    二叉树的遍历
    2.1最长递增子序列动态规划解法
    二叉树遍历分析(后缀算法的灵魂)
    记一次hive提交spark任务报错
    Ue4 CharacterMovementComponent 角色移动组件
    Ue4 TArray的属性同步
    Python 特殊语法 filter、map、reduce、lambda、yield
  • 原文地址:https://www.cnblogs.com/zfzf1/p/6910231.html
Copyright © 2020-2023  润新知