一、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. rdf-3x简要使用

    github下载地址:https://github.com/gh-rdf3x/gh-rdf3x rdf3x是用C++编写的,linux系统中,需要对其编译进行编译 1.安装g++编译器sudo apt ...

  2. SharePoint Visio Graphics Service-PowerShell

    1. 配置托管服务账户 Set-SPVisioExternalData -VisioServiceApplication "Visio Graphics Service" –Una ...

  3. [Linux] diff命令:逐行进行文件比较

    1. 比较文件 $ diff file1 file2 2. 比较文件夹 $ diff -urNa dir1 dir2 -u, -U NUM, --unified[=NUM] output NUM (d ...

  4. 最大似然估计和最大后验概率MAP

    最大似然估计是一种奇妙的东西,我觉得发明这种估计的人特别才华.如果是我,觉得很难凭空想到这样做. 极大似然估计和贝叶斯估计分别代表了频率派和贝叶斯派的观点.频率派认为,参数是客观存在的,只是未知而矣. ...

  5. Android_ndk_jni_hello-jni_hacking

    /*************************************************************************** * Android_ndk_jni_hello ...

  6. chapter02 svm对手写体数字的数码图像进行识别

    #coding=utf8 # 从sklearn.datasets里导入手写体数字加载器. from sklearn.datasets import load_digits # 从sklearn.cro ...

  7. liunx服务程序的安装及配置

    1.系统运行级别:

  8. PR5

    修改字幕的两种方式

  9. 网络流--最小费用最大流MCMF模板

    标准大白书式模板 #include<stdio.h> //大概这么多头文件昂 #include<string.h> #include<vector> #includ ...

  10. (转)C++ 容器及选用总结

    目录 ==================================================== 第一章 容器 第二章 Vector和string 第三章 关联容器 第四章 迭代器 第五 ...