zoukankan      html  css  js  c++  java
  • MyBatis(3.2.3)

    MyBatis's mapped statements have the parameterType attribute to specify the type of input parameter. If we want to pass multiple input parameters to a mapped statement, we can put all the input parameters in a HashMap and pass it to that mapped statement.

    MyBatis provides another way of passing multiple input parameters to a mapped statement. Suppose we want to find students with the given name and email.

    public interface StudentMapper {
        List<Student> findAllStudentsByNameEmail(String name, String email);
    }

    MyBatis supports passing multiple input parameters to a mapped statement and referencing them using the #{param} syntax.

    <select id="findAllStudentsByNameEmail" resultMap="StudentResult">
        select stud_id, name,email, phone from Students where name = #{param1} and email = #{param2}
    </select>

    Here #{param1} refers to the first parameter name and #{param2} refers to the second parameter email.

    StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
    studentMapper.findAllStudentsByNameEmail(name, email);
  • 相关阅读:
    模拟退火大法好
    宿命的PSS
    博客在summeroi.top上更新
    SPFA模板
    BZOJ 4551: [Tjoi2016&Heoi2016]树
    BZOJ 4152: [AMPPZ2014]The Captain
    BZOJ 3930: [CQOI2015]选数
    BZOJ 3875: [Ahoi2014&Jsoi2014]骑士游戏
    BZOJ4318: OSU!
    BZOJ3170: [Tjoi 2013]松鼠聚会
  • 原文地址:https://www.cnblogs.com/huey/p/5231695.html
Copyright © 2011-2022 走看看