MyBatis基础用法(一)
<select id="getErrorTimes" resultType="Integer">
SELECT ErrorTimes FROM `employee_sensitive` WHERE `EmpId`=#{empId};
</select>
上述XML中,ErrorTimes为Integer类型,在接口中我如下声明:
Integer getErrorTimes(@Param("empId") Integer empId);
大多数情况下是没有问题的,但是有一种情况会出问题,就是在empId会查出多个列时候,程序报错。
所以接口改为如下就正确:
List<Integer> getErrorTimes(@Param("empId") Integer empId);
这也说明了一个事情,ResultType支持一个值或者一个List将其封装。
MyBatis基础用法(一)的更多相关文章
- SpringBoot示例教程(一)MySQL与Mybatis基础用法
示例需求 在Springboot2框架中,使用Mysql和Mybatis功能:1. Mysql+Datasource集成2. Mybatis+XML用法详解 数据库准备 采用了Oracle中的scot ...
- MyBatis基础入门《四》接口方式.Select查询集合
MyBatis基础入门<四>接口方式.Select查询集合 描述: 在<MyBatis基础入门<二>Select查询>中有说过,SQLSession有两种用法,这里 ...
- PropertyGrid控件由浅入深(二):基础用法
目录 PropertyGrid控件由浅入深(一):文章大纲 PropertyGrid控件由浅入深(二):基础用法 控件的外观构成 控件的外观构成如下图所示: PropertyGrid控件包含以下几个要 ...
- logstash安装与基础用法
若是搭建elk,建议先安装好elasticsearch 来自官网,版本为2.3 wget -c https://download.elastic.co/logstash/logstash/packag ...
- elasticsearch安装与基础用法
来自官网,版本为2.3 注意elasticsearch依赖jdk,2.3依赖jdk7 下载rpm包并安装 wget -c https://download.elastic.co/elasticsear ...
- BigDecimal最基础用法
BigDecimal最基础用法 用字符串生成的BigDecimal是不会丢精度的. 简单除法. public class DemoBigDecimal { public static void mai ...
- myBatis 基础测试 表关联关系配置 集合 测试
myBatis 基础测试 表关联关系配置 集合 测试 测试myelipse项目源码 sql 下载 http://download.csdn.net/detail/liangrui1988/599388 ...
- Vue组件基础用法
前面的话 组件(Component)是Vue.js最强大的功能之一.组件可以扩展HTML元素,封装可重用的代码.根据项目需求,抽象出一些组件,每个组件里包含了展现.功能和样式.每个页面,根据自己所需, ...
- Mybatis基本用法--下
Mybatis基本用法--下 第七部分 mybatis-spring-boot-starter 官网:http://www.mybatis.org/spring-boot-starter/mybati ...
随机推荐
- spark java 代码example
https://github.com/apache/spark/tree/master/examples/src/main/java/org/apache/spark/examples
- php编译错误Note that the MySQL client library is not bundled anymore!
Note that the MySQL client library is not bundled anymore! 解决方法. 1. 查看系统有没有安装mysql header find / -na ...
- 我的C笔记
最近更新: 1,父进程fork一个子进程,当向父进程发送一个SIGINT或其它信号时,子进程是否会接受到该信号? 2,父进程调用system执行一个程序时,向父进程发送一个信号时,system运行中的 ...
- Java中判断字符串中相同字符的个数
public static int countStr(String str1, String str2) { int counter=0; if (str1.indexOf(str2) == -1) ...
- dip2px
package com.itheima.zhbj.utils; import android.content.Context; public class DensityUtils { public s ...
- PHP扩展开发-简单类扩展
今天来学习简单类扩展开发 实现目标为如下php的类 <?php class classext(){ private $username; CONST URL="http://www.g ...
- 推翻自己和过往,重学自定义View
http://blog.csdn.net/lfdfhl/article/details/51671038 深入探讨Android异步精髓Handler 站在源码的肩膀上全解Scroller工作机制 A ...
- sql server中单引号拼接字符串(书写错误会出现错误"浮点值 XXXX 超出了计算机表示范围(8 个字节)。“XX”附近有语法错误。")
" ' "(单引号)的运用:在sql server中,两个" ' "(单引号)在拼接字符串的情况下运用,就是表示拼接上了一个" ' "单引号 ...
- How to Iterate Over a Map in Java?(如何遍历Map)
1.Iterate through the "entrySet" like so: public static void printMap(Map mp) { Iterator i ...
- Singleton ——运行时全局唯一对象
Singleton 运行时全局唯一对象 Singleton模式只解决一个问题,如何做到运行时创建一个全局唯一的对象? 1:隐藏类的实例化操作,即将构造函数声明为private或protected.任何 ...