在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. Asp.net容器化

    注意:本文只用于探讨asp.net容器化,不建议生产环境下使用(docker 镜像太大!!!!) 安装docker 准备一个台windwos server 2016 ,在PowerShell 里执行以 ...

  2. JSON(四)——异步请求中前后端使用Json格式的数据进行交互

    json格式的数据广泛应用于异步请求中前后端的数据交互,本文主要介绍几种使用场景和使用方法. 一,json格式字符串 <input type="button" id=&quo ...

  3. 【笔记】快应用QuickApp(hap) -- 构建一个微博应用

    一.背景 在上次和小伙伴分享了快应用(后面简称hap)后,有很多待定的思路没有去尝试.这周有时间简单开发了一个热门微博的应用,主要涉及到的难点:富文本.长列表.画廊.这里将整个开发过程中遇到的问题以及 ...

  4. POJ-3295 Tautology---栈+表达式求值

    题目链接: https://vjudge.net/problem/POJ-3295 题目大意: 输入由p.q.r.s.t.K.A.N.C.E共10个字母组成的逻辑表达式WFF      其中      ...

  5. css3 box-shadow阴影(外阴影与外发光)

    基础说明:     外阴影:box-shadow: X轴  Y轴  Rpx  color;     属性说明(顺序依次对应): 阴影的X轴(可以使用负值)    阴影的Y轴(可以使用负值)    阴影 ...

  6. C#之Message(转)

    一.消息概述 Windows下应用程序的执行是通过消息驱动的.消息是整个应用程序的工作引擎,我们需要理解掌握我们使用的编程语言是如何封装消息的原理. 什么是消息(Message) 消息就是通知和命令. ...

  7. Now trying to drop the old temporary tablespace, the session hangs.

    1.描述 问题描述:删除临时表空间时,会话Hangs挂起 SQL> drop tablespace TEMP_B including contents and datafiles; 2.故障诊断 ...

  8. java的继承性

    在java继承中,子类也称为派生类,父类也称为基类或者超类,基本语法 :子类 extends 父类{} 实现一个简单的继承类: class Person{ private String name; p ...

  9. [LeetCode] Coin Change 2 硬币找零之二

    You are given coins of different denominations and a total amount of money. Write a function to comp ...

  10. [LeetCode] Next Greater Element I 下一个较大的元素之一

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...