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 ...
随机推荐
- 从PRISM开始学WPF(八)導航Navigation?
0x6Navigation Basic Navigation Prism中的Navigation提供了一种类似导航的功能,他可以根据用户的输入,来刷新UI. 先看一个最简单的例子,通过按钮来导航到一个 ...
- dubbo的InvocationChain
个人觉得dubbo比较好的设计是:一个是Cooma微容器设计.另一个就是InvocationChain了 Cooma微容器是自己实现了一套SPI,方便了用户做扩展: InvocationChain类似 ...
- 新概念英语(1-121)The man in a hat
Why didn't Caroline recognize the customer straight away ?A:I bought two expensive dictionaries here ...
- OAuth2.0学习(1-8) 授权方式五之Access_Token令牌过期更新
OAuth2.0的Access_Token令牌过期更新 如果用户访问的时候,客户端的"访问令牌"已经过期,则需要使用"更新令牌"申请一个新的访问令牌. 客户端发 ...
- TensorFlow-Slim使用方法说明
翻译自:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim TensorFlow-Slim TF- ...
- Text-查找文本
from tkinter import * master=Tk() text=Text(master,width=30,height=5) text.pack() text.insert(INSERT ...
- [LeetCode] Base 7 基数七
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- 跨域访问 - 跨域请求 同源策略概念对跨域请求的影响 及几种解决跨域请求的方法如 jsonp
为什么会设置同源策略 > 适用于浏览器的一种资源访问策略 > 同源策略(Same origin policy)是一种约定,它是浏览器最核 心也最 基本的安全功能,如果缺少了同源策略,则浏览 ...
- SpringIOC学习一
Spring是一个轻量级的控制反转(IOC)和面向切面(IOP)的容器框架1.控制反转IOC(inversion of controller) IOC是一种概念,是把我们程序中类与类之间的依赖关 ...
- servlet之cookie实现
三个servlet的实现: package app02c;import java.io.IOException;import java.io.PrintWriter;import javax.serv ...