MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
描述:

2021-08-xx 13:31:30.049 DEBUG 9208 : ==> Preparing: SELECT SUM(end_vt) - SUM(start_vt) FROM s_dc_volume where ADDITION = 0 and START_TIME >= ? and END_TIME <= ?
2021-08-xx 13:31:30.050 DEBUG 9208 : ==> Parameters: 2021-06-01 20:57:00.0(Timestamp), 2021-08-29 19:37:00.0(Timestamp)
2021-08-xx 13:31:30.201 DEBUG 9208 : <== Total: 2 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:78)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
at com.sun.proxy.$Proxy92.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:89)
错误描述
分析:
1.项目使用了sharding对s_dc_volume进行分表,查询范围涉及到多个子表
2.mapper方法接收直接使用数字类型,未使用list

BigDecimal getSumVolume(Date startTime, Date endTime);
<select id="getSumVolume" resultType="java.math.BigDecimal">
SELECT SUM(end_vt) - SUM(start_vt)
FROM s_dc_volume
where and ADDITION = 0
and START_TIME <![CDATA[ >=]]> #{startTime}
and END_TIME <![CDATA[ <=]]> #{endTime}
</select>
mapper源码
结论:
sharding使用sum求和时具体到每个子表中求和,对于跨表查询时,会返回多个结果
sharding官网:
https://shardingsphere.apache.org/document/current/cn/features/sharding/use-norms/sql/
MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2的更多相关文章
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3报错解决
报错的原因翻译出来: 预期的一个结果(或null)返回selectOne(),但发现:3 意思就是你想得到一个结果值,但是返回了三个结果值. 一般可能测试的时候我们存了几条一样的数据,在登录时,会把同 ...
- Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
异常信息 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with na ...
- HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.e ...
- 错误信息: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
这个错误主要原因是:数据库的配置出问题,比如写错库名什么的,仔细检查下.
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]
Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...
- 解决:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'requestMap.maintenancename != null and requestMap.maintenance
异常如下:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Builde ...
- 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param
错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...
- 【异常及源码分析】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping
一.异常出现的场景 1)异常出现的SQL @Select("SELECT\n" + " id,discount_type ,min_charge, ${cardFee} ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [arg1, arg0, param1, param2]
2018-06-27 16:43:45.552 INFO 16932 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : ...
- SpringMvc错误:HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is n
HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemExc ...
随机推荐
- 申威CPU的简单知识梳理
摘要 最近有客户要用申威服务器了 自己很早之前简单测试过相关的CPU的服务器 但是感觉很多东西都不是很系统. 今天简单收集一下资料 希望对以后的工作有所帮助 申威CPU的创始 申威是解放军总参谋部第五 ...
- 使用rpmbuild打包erlang和rabbitmq进行部署服务的方法
使用rpmbuild打包erlang和rabbitmq进行部署服务的方法 背景说明 1. rabbitmq 是基于 erlang 开发的消息列队, 本身rabbitmq 自己不区分架构. 2. 但是e ...
- 利用pearcmd.php本地文件包含(LFI)
本文主要是为了学习如何用pearcmd进行本地文件包含 0x00 环境准备 首先先在docker中安装一个php环境. docker exec -it [container id] /bin/bas ...
- ClickHouse(08)ClickHouse表引擎概况
目录 合并树家族 日志引擎系列 集成的表引擎 其他特殊的引擎 资料分享 参考文章 目前ClickHouse的表引擎主要有下面四个系列,合并树家族.日志引擎系列.集成的表引擎和其他特殊的引擎. 合并树家 ...
- 2020第二届长安杯wp
1 检材 1 的操作系统版本是 A. CentOS release 6.5 (Final) B. Ubuntu 16.04.3 LTS C. Debian GNU/Linux 7.8 (wheezy) ...
- 深入学习C#系列文章01---C#3 革新写代码的新方式
C#3 几乎所有的新特性都是为LINQ服务的,但他们单独使用也非常有用,接下来我们来简单看看C#3 的几个新特性吧. 一.自动实现的属性-----编写由字段直接支持的简单属性,不再显得臃肿不堪. 之前 ...
- 离线下载和安装UWP(windows应用商店)软件
离线下载uwp安装包 打开商店,然后搜索您要的应用程序名称,进入应用界面 点击 分享按钮,在弹出窗口中选择[复制链接] 把链接粘贴到:https://store.rg-adguard.net/ 默认选 ...
- C#对象属性浅拷贝和深拷贝
对象属性和字段拷贝的几种方式 微软提供了浅拷贝 对于值类型,修改拷贝的值不会影响源对象 对于引用类型,修改拷贝后的值会影响源对象,但string特殊,它会拷贝一个副本,互相不会影响 自己实现深拷贝,我 ...
- 28图图解Raft协议,so easy~~
大家好,我是三友~~ 在之前写的<万字+20张图探秘Nacos注册中心核心实现原理> 这篇文章中我留了一个彩蛋 当文章点赞量突破28个,就单独写一篇关于Raft协议的文章 既然现在文章点赞 ...
- 14代i5-14600K现身:多核性能提升多达11%
14代酷睿桌面端还未发售,就陆续在跑分平台上露出. 平台规格为Z790主板.32GB DDR5-5200内存,酷睿i5-14600K的单核成绩为2819,多核成绩为16666,对比酷睿i5-13600 ...