zoukankan      html  css  js  c++  java
  • 【mybatis】传多个参数的问题

    一般我们传参都是一个参数或者一个实体类。

    当我们的需要传参,实体类又没有这个属性,我们又不想在实体类添加那个属性时候我们可以这么写。(一个实体类,一个string)

    直接上Mapper层

    //使用@Param注解指定入参的名称
    List<LwgyBaseStudent> queryStudent(@Param("lwscl") School school,@Param("studentSex") String studentSex);

    mapper.xml

    <select id="queryStudentByCode" resultType="Student"
                parameterType="School">
        SELECT
            s.id,
            s.student_name,
            s.student_number,
            s.student_idcard,
            s.student_sex,
            s.student_phone,
            IF (b.id IS NULL, '0', '1') AS isBed,
            b.`name` AS bedName
            FROM
            `lwgy_base_student` s
            LEFT JOIN lwgy_base_bed b ON s.id = b.student_id
            <where>
                    s.student_sex = #{studentSex}
                <if test="lwscl.universitySort=='xq'">
                    and student_campus = #{lwscl.id}
                </if>
                <if test="lwscl.universitySort=='xy'">
                    and student_college = #{lwscl.id}
                </if>
                <if test="lwscl.universitySort=='zy'">
                    and student_major = #{lwscl.id}
                </if>
                <if test="lwscl.universitySort=='bj'">
                    and student_class = #{lwscl.id}
                </if>
    
            </where>
        </select>
  • 相关阅读:
    django LDAP
    Python egg
    皮皮书屋
    Linux运维
    bash shell 快捷键汇总
    linux ldconfig
    Linux set env export declare unset
    OpenStack
    【LeetCode】258. Add Digits
    一个"Median Maintenance"问题
  • 原文地址:https://www.cnblogs.com/aioe/p/14602246.html
Copyright © 2011-2022 走看看