在MyBatis的select,insert,update,delete这些元素中都提到了parameterType这个属性。MyBatis现在使用parameterType有基本类型和JAVA复杂数据类型。

基本类型:包含int,String,Date等,基本数据类型作为传入参数,只能传入一个。通过#{参数名}即可获取传入的值

复杂类型:包含JAVA实体类,Map,通过#{属性名}或#{Map的keyName}即可获取传入的值。

1.基本类型参数示例

xml文件

<select id="selectName"   parameterType="int"   resultType="com.domain.Person">

    select * from tableName where id = #{id}

</select>

Java代码

List<Person> plist = Mapper.selectPerson();

for(Person persion:plist){

System.out.println(persion.toString());

}

.JAVA 实体类型参数示例

xml文件

<select id="selectName"   parameterType="com.domain.Person"   resultType="com.domain.Person">

    select * from tableName where id = #{id}

</select>

Java代码

Person person = new Person();

person.setId();

List<Person>  plist  =  Mapper.selectPerson(person)

for(Person person : plist){

System.out.println(person.toString());

}

.Map参数示例

xml文件

<select id="selectName"   parameterType="Map"   resultType="com.domain.Person">

    select * from tableName where id = #{id} and sex=#{sex}

</select>

Java代码

Map<String,String> map = new HasMap<String,String>();

map.put("id",);

map.put("sex","男");

List<Person> plist  = Mapper.selectPerson(map);

for(Person person:plist){

System.out.println(person.toString());

}

MyBatis 传入参数之parameterType的更多相关文章

  1. mybatis传入参数类型parameterType和输出结果类型resultType详解

    前言 Mybatis的Mapper文件中的select.insert.update.delete元素中都有一个parameterType和resultType属性,parameterType属性用于对 ...

  2. mybatis传入参数类型parameterType详解

    前言 Mybatis的Mapper文件中的select.insert.update.delete元素中都有一个parameterType属性,用于对应的mapper接口方法接受的参数类型. ( res ...

  3. MyBatis传入参数与parameterType

    参考:http://openwares.net/database/mybatis_parametertype.html Mybatis的Mapper文件中的select.insert.update.d ...

  4. MyBatis传入参数为list、数组、map写法

    1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item,index,collection,open,sep ...

  5. MyBatis传入参数为list、数组、map写法(转载)

    MyBatis传入参数为list.数组.map写法 1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item ...

  6. MyBatis传入参数

    在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和Ja ...

  7. MyBatis传入参数为集合、数组SQL写法

    参考:http://blog.csdn.net/small____fish/article/details/8029030 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合 ...

  8. MyBatis传入参数为集合 list 数组 map写法

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的属性主要有item,index,collection,open,separator,close.ite ...

  9. Mybatis传入参数类型为Map

    mybatis更新sql语句: <update id="publishT00_notice" parameterType="Map"> update ...

随机推荐

  1. Python内置函数(10)——float

    英文文档: class float([x]) Return a floating point number constructed from a number or string x. If the ...

  2. SpringBoot应用的监控与管理

    spring-boot-starter-actuator模块 /health /autoconfig /beans /configprops:应用配置属性信息 /env:环境属性,如:环境变量.jvm ...

  3. angular2 学习笔记 ( 第3方插件 jQuery and ckeditor )

    refer : https://forums.meteor.com/t/importing-ckeditor-using-npm/28919/2   (ckeditor) https://github ...

  4. spring2——IOC之Bean的装配

    spring容器对于bean的装配提供了两个接口容器分别是"ApplicationContext接口容器"和"BeanFactory接口容器",其中" ...

  5. Intent 的两种主要使用方法

    首先建立两个activity界面 Activity1如下 public class MainActivity extends AppCompatActivity { private Button bt ...

  6. CMDB开发

    浅谈ITIL TIL即IT基础架构库(Information Technology Infrastructure Library, ITIL,信息技术基础架构库)由英国政府部门CCTA(Central ...

  7. hdu1022 Train Problem I---模拟栈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 题目大意: 车的进出站问题,先给出N个火车,再按序列一的方式进站,判断能否以序列二的方式出站,若 ...

  8. [论文阅读] ImageNet Classification with Deep Convolutional Neural Networks(传说中的AlexNet)

    这篇文章使用的AlexNet网络,在2012年的ImageNet(ILSVRC-2012)竞赛中获得第一名,top-5的测试误差为15.3%,相比于第二名26.2%的误差降低了不少. 本文的创新点: ...

  9. selenium用法详解

    selenium用法详解 selenium主要是用来做自动化测试,支持多种浏览器,爬虫中主要用来解决JavaScript渲染问题. 模拟浏览器进行网页加载,当requests,urllib无法正常获取 ...

  10. js通过class获取元素时的兼容性解决方案

    1:::::方法代码如下:function getByClass(sClass){    var aResult=[];    var aEle=document.getElementsByTagNa ...