一、mybatis传入多个参数:

前面讲传入多个参数都是使用map,hashmap:key value的形式;-- 项目中开发都建议使用map传参;
比如现在通过两个参数,name和age来查询;
通过两个参数来查的,了解下就行了;
 
数据库中存在t_student记录:
1)测试代码StudentTest.java:
@Test
public void testSearchStudents() {
logger.info("根据name和age查询学生");
List<Student> studentList=studentMapper.searchStudent("%zhang%",14);
for(Student student:studentList){
logger.info(student);
}
}

2)StudentMapper.java接口:

//根据多个参数获取student:
public List<Student> searchStudent(String name, int age);

3)StudentMapper.xml映射文件:

<!-- 根据多个参数查询学生 -->
<select id="searchStudent" resultType="Student">
select * from t_student where name like #{param1} and age=#{param2}
</select>

console打印:

小峰mybatis(2)mybatis传入多个参数等..的更多相关文章

  1. mybatis从dao传入多个参数到sqlmap时dao中要使用map或实例对象(如:user)作为参数传入, 否则报错找不到属性getter方法

    23:37 2015-07-02 注意1. 使用mybaits的resultMap查询时, 如果想传入多个参数(比如where 1=1动态多条件查询时)sqlmap文件中对应的方法中, selectL ...

  2. Mybatis的parameterType传入多个参数

    如果查询的条件有多个的时候,mybatis有三种传入方式: 1.通过注解传入 例如: public interface Mapper(){ public User login(@Param(" ...

  3. Mybatis 向statement传入多个参数

    1.一般情况下可以将多个参数放入Map,让Map作为statement的参数 public void update(@Param("fieldMap") Map<String ...

  4. 每日一记-mybatis碰到的疑惑:String类型可以传入多个参数吗

    碰到一个觉得很疑惑的问题,Mybatis的parameterType为String类型的时候,能够接收多个参数的吗? 背景 初学Mybatis的时候,看的教程和书籍上都是在说基本的数据类型如:int. ...

  5. mybatis传入多个参数

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  6. Mybatis 接口传入多个参数 xml怎么接收

    mybatis 在接口上传入多个参数 1.如果传入的参数类型一样. Map<String, String> queryDkpayBindBankCidByOriBindAndBankCid ...

  7. <MyBatis>入门四 传入的参数处理

    1.单个参数 传入单个参数时,mapper文件中 #{}里可以写任意值 /** * 传入单个参数 */ Employee getEmpById(Integer id); <!--单个参数 #{} ...

  8. (转)MyBatis传入多个参数的问题

    背景:记录mybaitis的使用方法,博闻强记,后面尽量记忆使用. MyBatis传入多个参数的问题 MyBatis传入多个参数的问题 详细记录mybatis在传递多个参数时候的使用方法 关于Myba ...

  9. MyBatis如何传入多个参数

    一.单个参数 mapper public List<Test> getTestList(String id); xml <select id = "getTestList& ...

随机推荐

  1. 常用docker

    随便什么版本的linux 接入daocloud.io 在发现镜像中选择DockerHub 搜索对应的image,然后部署. 手动输入YAML即可 aria: image: cuteribs/aria2 ...

  2. 全球信息安全会议 Top 50

    信息安全会议在世界范围内举办,下面是全球最值得参加的50个信息安全会议的简介,以时间顺序列出.需要注意的是,这份清单基于2016年的信息撰写,因为具体日期与地点每年或有不同,请至活动官网确认具体的日期 ...

  3. bacula备份终端操作bconsole指令

    1.list命令列出各种备份状态信息   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 list Jobs     #列出所有备份记录状态 list jobid= ...

  4. Android2.1消息应用(Messaging)

    我想首先应该从AndroidManifest.xml文件开始,该文件是Android应用(APK)的打包清单,其中提供了关于这个应用程序的基本信息,如名称(application/@label),图标 ...

  5. C#中数组数据类型字符串转double型问题

    再给你说一下我的意思吧.有一个string类型的数组a,a中的每一个元素实际上是一个小数,现在是想把a中的这些小数全都从string型转换成double类型,最后组成一个double型的数组b,说白了 ...

  6. mysql 下载和 安装

    一.下载mysql 1. 在浏览器里打开mysql的官网http://www.mysql.com/ 2. 进入页面顶部的"Downloads" 3. 打开页面底部的“Communi ...

  7. ubuntu16 intellij idea install lombok plugin

    项目中用到lombok,idea会出现类似编译报错的红色,但并不影响运行.所以为了没有类似警告,就在idea上安装lombok插件.file-settings 安装完成之后,按照提示重启idea,问题 ...

  8. PHP连接MYSQL 报错"No such file or directory"

    首先确定是mysql_connect()和mysql_pconnect()的问题,故障现象就是函数返回空,而mysql_error()返回“No such file or directory”. 写个 ...

  9. mkbootimg hacking

    /********************************************************************** * mkbootimg hacking * 声明: * ...

  10. I.MX6_Linux_UART_device&driver_hacking

    /****************************************************************************************** * I.MX6_ ...