在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. big_menu菜单设置

    1.页面 <script> $(function(){ $('.subnav .content-menu .on').after('<a class="add fb&quo ...

  2. 大数据学习总结(7)we should...

    大数据场景一.各种标签查询 查询要素:人.事.物.单位 查询范围:A范围.B范围.... 查询结果:pic.name.data from 1.痛点:对所有文本皆有实时查询需求2.难点:传统SQL使用W ...

  3. MSSQl 事务的使用

    事务具有以下四个特性: 1.原子性 事务的原子性是指事务中包含的所有操作要么全做,要么全不做. 2.一致性 在事务开始以前,数据库处于一致性的状态,事务结束后,数据库也必须处于一致性状态. 3.隔离性 ...

  4. UVA-562 Dividing coins---01背包+平分钱币

    题目链接: https://vjudge.net/problem/UVA-562 题目大意: 给定n个硬币,要求将这些硬币平分以使两个人获得的钱尽量多,求两个人分到的钱最小差值 思路: 它所给出的n个 ...

  5. Canvas绘制五角星

    from tkinter import * import math as m root = Tk() w = Canvas(root, width=200, height=100, backgroun ...

  6. jquery楼层效果

  7. 使用 C# (.NET Core) 实现命令设计模式 (Command Pattern)

    本文的概念内容来自深入浅出设计模式一书. 项目需求 有这样一个可编程的新型遥控器, 它有7个可编程插槽, 每个插槽可连接不同的家用电器设备. 每个插槽对应两个按钮: 开, 关(ON, OFF). 此外 ...

  8. Ubuntu Sublime 配置

    p { margin-bottom: 0.25cm; line-height: 120% } a:link { } 2018.4.14 Ubuntu Sublime 配置 承 Ubuntu Apach ...

  9. Java集合框架知多少——干货!!!

    Java集合框架的组成 注意:四个接口的区别 ① Collection:存储无序的.不唯一的数据: ② List:存储有序的.不唯一的数据: ③ Set:存储无序的.唯一的数据: ④ Map:以键值对 ...

  10. python 函数“四剑客”的使用和介绍

    python函数四剑客:lambda.map.filter和reduce. 一.lambda(匿名函数) 1. 学习lambda要注意一下几点: lambda语句被用来创建新的函数对象,并且在运行的时 ...