MyBatis处理一行数据-MyBatis使用sum语句报错-MyBatis字段映射-遁地龙卷风
第二版
(-1)写在前面
我用的是MyBatis 3.2.4
(0) 编程轶事
select sum(value) ,sum(value2) from integral_list where MemberId = #{0} and operate = 1 and Year(AddTime) = #{1} and ChannelType = #{2} and ChannelCode = #{3}
我用的sqlyoug显示的的字段名分别是sum(value) 、sum(value2)
我在xml文件中返回值类型是实体类的别名,由于mybatis根据数据库字段名找到实体类字段的set方法确认这个字段是否存在
我将语句改为如下便正确了
select sum(value) as 'value',sum(value2) as 'value2' from integral_list where MemberId = #{0} and operate = 1 and Year(AddTime) = #{1} and ChannelType = #{2} and ChannelCode = #{3}
顺便说一下如何接收返回值,因为执行语句返回的结果集是一行数据两个字段,可以用hashmap
配置文件关键部分为:
<select
resultType="hashmap">
实体类映射xml文件关键部分为:
HashMap<String,
BigDecimal>
得到的结果结构为
key value
“value”
28.0
“value2”
8.0
对于加班我的感触是:以前学习花钱,现在学习挣钱。


MyBatis处理一行数据-MyBatis使用sum语句报错-MyBatis字段映射-遁地龙卷风的更多相关文章
- 【mybatis】【mysql】mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains no ...
- SQL Server中事务transaction如果没写在try catch中,就算中间语句报错还是会提交
假如我们数据库中有两张表Person和Book Person表: CREATE TABLE [dbo].[Person]( ,) NOT NULL, ) NULL, ) NULL, [CreateTi ...
- 解决Mysql搭建成功后执行sql语句报错以及区分大小写问题
刚搭建完mysql 8.0以后会: 一.表区分大小写, 二.执行正确的sql语句成功且会报:[Err] 1055 - Expression #1 of ORDER BY clause is not i ...
- SQL语句报错(一)
SQL语句报错(一) 1.具体报错如下: ORA-01861:文字格式字符串不匹配 01861. 00000 - "literal does not match format string& ...
- (转)android import library switch语句报错case expressions must be constant expressions
今天当我从github上下载一个工程,并把它的库文件导入eclipse中,发现switch语句报错case expressions must be constant expressions : 解决方 ...
- 普通的jdbc事务在插入数据后 下面的代码报错时 数据不会回滚 但是 spring的事务会回滚
普通的jdbc事务在插入数据后 下面的代码报错时 数据不会回滚 但是 spring的事务会回滚
- mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg
mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg ...
- 数据库查询语句报错-ORA-00911: invalid character
数据库查询语句报错-ORA-00911: invalid character 根据自己经验总结下: 1.都是分号惹的祸,有时候sql语句后面有分好导致这种错误 2.还有一种是从别处copy过来的sql ...
- Sqoop- sqoop将mysql数据表导入到hive报错
sqoop将mysql数据表导入到hive报错 [root@ip---- lib]# sqoop import --connect jdbc:mysql://54.223.175.12:3308/gx ...
随机推荐
- docker学习(3) 容器的启动过程
这一节我们来稍微了解下docker原理性的东西 docker run -i -t ubuntu /bin/bash 输入上面这行命令,启动一个ubuntu容器时,到底发生了什么? 大致过程可以用下图描 ...
- [LeetCode] Search Insert Position 搜索插入位置
Given a sorted array and a target value, return the index if the target is found. If not, return the ...
- 值得注意的IsHitTestVisible
这个属性我们平时可能并不怎么用.先来看下MSDN上的解释: 解释的非常专业,然而我并没有看懂. 说说我的理解吧:把这个属性设置为false,看起来没有变化,但操作上已经把他完全忽视了,不触发事件,可以 ...
- maven webapp栽坑录
一.需求 如何将一个java web项目传给别人?放到github上.要想放到github上,就要学会git,markdown和maven.像那些jar包是不鼓励传到github上的,应该尽量把源文件 ...
- Quartz定时任务
spring多个定时任务quartz配置 例子1: biz-quartz-context.xml配置 <?xml version="1.0" encoding="U ...
- PDF.NET内存数据库的使用小结
深蓝医生的PDF.NET数据开发框架提供了一个建议的内存数据库功能,具体的功能介绍我就不多说了,可以看医生的博文<移花接木:当泛型方法遇上抽象类----我的“内存数据库”诞生记>. 我之所 ...
- 将字符串中的URL 解析,获取内容
parse_str() : parse_str("name=Bill&age=60"); echo $name."<br>";//Bill ...
- Android测试基础题(三)
今天接着给大家带来的是Android测试基础题(三). 需求:定义一个排序的方法,根据用户传入的double类型数组进行排序,并返回排序后的数组 俗话说的好:温故而知新,可以为师矣 packag ...
- 收集移动端HTML5/H5使用的插件
日期: http://t.cn/R2UOFoW 地区: http://www.jq22.com/jquery-info8371 头像: http://fex.baidu.com/webuploader ...
- CTP程序化系统开发(C++ && PHP)
2016-12-13 11:03:52 借助CTP的DEMO(上海期货交易公司提供的), 需要自己在 http://www.simnow.com.cn 上注册账号, 再者,需要下载[博易大师]软件, ...