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 ...
随机推荐
- CentOS 7.0系统安装配置步骤详解
CentOS 7.0系统是一个很新的版本哦,很多朋友都不知道CentOS 7.0系统是怎么去安装配置的哦,因为centos7.0与以前版本是有很大的改进哦. 说明: 截止目前CentOS 7.x最新版 ...
- [LeetCode] Longest Increasing Subsequence 最长递增子序列
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...
- [LeetCode] Word Break II 拆分词句之二
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each ...
- 【WPF】Combobox指定选中值用selectedValue不是很灵的时候,
wpf combobox 指定选中的值,前题,combobox是通过数据库绑定的ItemsSource:所以再指定的时候用selectValue不是很成功!我的解决方法是 生成一个字典,办值和索引对应 ...
- ubuntu系统虚拟机下共享文件夹
一般情况 1.安装: sudo apt-get install open-vm-dkms 2.挂载: sudo mount -t vmhgfs .host:/ /mnt/hgfs 用以上命令安 ...
- 常用SQL
1. CEILING 向上取整2. FLOOR 向下取整3. FORMATmysql> SELECT FORMAT(12332.123456, 4); -> '12,332.1235'my ...
- 《Just for Fun》读后感
这本书有一个长长的中文名字:<只是为了好玩:Linux之父林纳斯自传>,所以博客标题我就用英文书名了. 读罢此书,不禁想起一位长者的名言:“一个人的成功当然要靠自我奋斗,但也要考虑历史的进 ...
- HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对 ...
- 浅谈:javascript的面向对象编程之基础知识的介绍
在进入javascript的面对对象之前,我们先来介绍一下javascript的几个概念. 1.javascript的面向对象的基本概念 function aa(){ } /* * 这里的aa,在我们 ...
- Table 表单样式
<style> table th { white-space: nowrap; background-color: #f5f5f5; height:30px; font-size:14px ...