MyBatis 传入参数之parameterType
在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的更多相关文章
- mybatis传入参数类型parameterType和输出结果类型resultType详解
前言 Mybatis的Mapper文件中的select.insert.update.delete元素中都有一个parameterType和resultType属性,parameterType属性用于对 ...
- mybatis传入参数类型parameterType详解
前言 Mybatis的Mapper文件中的select.insert.update.delete元素中都有一个parameterType属性,用于对应的mapper接口方法接受的参数类型. ( res ...
- MyBatis传入参数与parameterType
参考:http://openwares.net/database/mybatis_parametertype.html Mybatis的Mapper文件中的select.insert.update.d ...
- MyBatis传入参数为list、数组、map写法
1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item,index,collection,open,sep ...
- MyBatis传入参数为list、数组、map写法(转载)
MyBatis传入参数为list.数组.map写法 1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item ...
- MyBatis传入参数
在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和Ja ...
- MyBatis传入参数为集合、数组SQL写法
参考:http://blog.csdn.net/small____fish/article/details/8029030 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合 ...
- MyBatis传入参数为集合 list 数组 map写法
foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的属性主要有item,index,collection,open,separator,close.ite ...
- Mybatis传入参数类型为Map
mybatis更新sql语句: <update id="publishT00_notice" parameterType="Map"> update ...
随机推荐
- 使用 dynamic 类型让 ASP.NET Core 实现 HATEOAS 结构的 RESTtful API
上一篇写的是使用静态基类方法的实现步骤: http://www.cnblogs.com/cgzl/p/8726805.html 使用dynamic (ExpandoObject)的好处就是可以动态组 ...
- Python内置函数(57)——print
英文文档: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) Print objects to the text str ...
- HTTP协议扫盲(一)HTTP协议的基本概念和通讯原理
一.HTTP协议的概念 1.引子 - 从url开始 URL(Uniform Resource Locator) 地址用于描述一个网络上的资源, 基本格式如下 schema://host[:port# ...
- Python REST
Django REST framework 1. 什么是REST REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译 ...
- Python操作SQLAchemy
如果对代码不懂就看这个:http://www.cnblogs.com/jixuege-1/p/6272888.html 本篇对于Python操作MySQL主要使用两种方式: 原生模块 pymsql O ...
- 二、配置QtDesigner、PyUIC及PyRcc
配置QtDesigner.PyUIC及PyRcc 安装完PyQt 5 及PyQt5-tools 后,则需要在Pycharm中配置QtDesigner.PyUIC及PyRcc. 配置QtDesigner ...
- JVM 性能调优监控工具
声明:本文转自<https://www.cnblogs.com/anxiao/p/6796644.html?utm_source=itdadao&utm_medium=referral& ...
- 深入理解.net - 1.继承的本质
最近偶然看到这个博客你必须知道的.net,作者6的飞起啊,干货十足,还是07年写的...写的也很赞,评论更精彩,在此强烈推荐一波,看的感觉就像沙漠里发现了绿洲一样,很兴奋,意犹未尽,迫不及待的看完一篇 ...
- 【转载】Ubuntu 12.04 LTS 中文输入法的安装
原文地址 : http://www.cnblogs.com/zhj5chengfeng/archive/2013/06/23/3150620.html 我装的是英文版的 Ubuntu12.04,如果 ...
- laydate 日期格式为yyyy 或yyyy-MM时,出现错误Uncaught TypeError: Cannot read property 'length' of undefined
这个改起比较麻烦,没有深究,简单兼容了yyyy 和yyyy-MM,其他格式可能还是会有错误.替换Dates.check方法. //检测日期是否合法 Dates.check = function(){ ...