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);

MyBatis(3.2.3) - Passing multiple input parameters的更多相关文章

  1. doris: shell invoke .sql script for doris and passing values for parameters in sql script.

    1. background in most cases, we want to execute sql script  in doris  routinely. using azkaban, to l ...

  2. C++ Templates(1.3 多模板参数 Multiple Template Parameters)

    返回完整目录 目录 1.3 多模板参数 Multiple Template Parameters 1.3.1 为返回类型设置模板参数参数 Template Parameters for Return ...

  3. JNI: Passing multiple parameters in the function signature for GetMethodID

    http://stackoverflow.com/questions/7940484/jni-passing-multiple-parameters-in-the-function-signature ...

  4. [Angular 2] Passing Template Input Values to Reducers

    Angular 2 allows you to pass values from inputs simply by referencing them in the template and passi ...

  5. Mybatis异常:java.lang.NumberFormatException: For input string: "S"

    MyBatis异常日志如下: Caused by: java.lang.NumberFormatException: For input string: "S" at sun.mi ...

  6. mybatis参数错误 Parameter '×××' not found. Available parameters are [0, 1, param1, param2]

    报错的代码 @Update("update staff_info set ApplyState = #{applyState} where Id = #{userId}") int ...

  7. Table of Contents - MyBatis

    Getting Started with MyBatis Hello World Integration with Spring Bootstrapping MyBatis Configuring M ...

  8. Callback<> and Bind()

    Callback<> and Bind() Introduction The templated base::Callback<> class is a generalized ...

  9. 【译】Android API 规范

    [译]Android API 规范 译者按: 修改R代码遇到Lint tool的报错,搜到了这篇文档,aosp仓库地址:Android API Guidelines. 58e9b5f Project ...

随机推荐

  1. 用6个字符写出任意的Javascript代码

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用6个字符写出任意的Javascript代码.

  2. 【每日一摩斯】-Index Skip Scan Feature (212391.1)

    INDEX Skip Scan,也就是索引快速扫描,一般是指谓词中不带复合索引第一列,但扫描索引块要快于扫描表的数据块,此时CBO会选择INDEX SS的方式. 官方讲的,这个概念也好理解,如果将复合 ...

  3. android UI进阶之实现listview的分页加载

    上篇博文和大家分享了下拉刷新,这是一个用户体验非常好的操作方式.新浪微薄就是使用这种方式的典型. 还有个问题,当用户从网络上读取微薄的时候,如果一 下子全部加载用户未读的微薄这将耗费比较长的时间,造成 ...

  4. 百度地图 web定位

    <!DOCTYPE html><html><head><meta charset="utf-8" /><meta name=& ...

  5. 分布式ActiveMQ集群--转载

    原文地址:http://shensy.iteye.com/blog/1752529 回顾总结前一段时间学习的ActiveMQ分布式集群相关的知识,分享出来希望对看到的人有所帮助. 一.分布式Activ ...

  6. 快递鸟电子面单API对接方法?

    之前说了一下快递公司.菜鸟和快递鸟的电子面单接口,很多人不知道快递鸟要怎么对接,现在为大家讲解一下.快递鸟是全球物流接口服务商,为电商 ERP.电商平台.仓储.清关公司提供物流跟踪.电子面单.智选物流 ...

  7. C#文件操作系列(一)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  8. hashTable(哈希表)的基本用法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...

  9. c语言实现:4和7幸运数字的题

    #include <stdio.h> #include <math.h> #include <vector> using namespace std; int ma ...

  10. sql server 2008 com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机

    右击我的电脑,点击管理 右击"TCP/IP"选择"属性"(或双击"TCP/IP"),选择"IP地址"选项卡,最下面有个& ...