描述:

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的更多相关文章

  1. 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 意思就是你想得到一个结果值,但是返回了三个结果值. 一般可能测试的时候我们存了几条一样的数据,在登录时,会把同 ...

  2. 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 ...

  3. 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 ...

  4. 错误信息: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

    这个错误主要原因是:数据库的配置出问题,比如写错库名什么的,仔细检查下.

  5. 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 ...

  6. 解决: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 ...

  7. 怪事年年有,今天特别多!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 ...

  8. 【异常及源码分析】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} ...

  9. 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].[/]       : ...

  10. 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 ...

随机推荐

  1. [转帖]TiUP 常见运维操作

    https://docs.pingcap.com/zh/tidb/stable/maintain-tidb-using-tiup 本文介绍了使用 TiUP 运维 TiDB 集群的常见操作,包括查看集群 ...

  2. [转帖]金仓数据库KingbaseES V8R6 索引膨胀

    索引膨胀 对于索引,随着业务不断的增删改,会造成膨胀,尤其Btree索引,也会涉及索引分裂.合并等,导致索引访问效率降低.维护成本增加.另外,索引页的复用与HEAP PAGE不一样,因为索引的内容是有 ...

  3. [转帖]CentOS7上systemctl的使用

    https://www.cnblogs.com/yeyuzhuanjia/p/14676182.html CentOS 7.x开始,CentOS开始使用systemd服务来代替daemon,原来管理系 ...

  4. [转帖]exportfs命令

    https://www.cnblogs.com/xzlive/p/9766388.html exportfs命令:功能说明 :NFS共享管理语法格式exportfs [必要参数][选择参数][目录]功 ...

  5. [转帖]看6大国产CPU加速替代,谁才是“王者”选手?

    https://baijiahao.baidu.com/s?id=1761150458273739276&wfr=spider&for=pc 2023-03-23 17:33湖北匠心计 ...

  6. [转帖]腾讯北极星 Polaris 试用

    https://www.cnblogs.com/QIAOXINGXING001/p/15482012.html 了解.试用 昨天稀土开发者大会2021提到了腾讯开源的北极星, 试用一下; 官网: 北极 ...

  7. IPMI的简单使用

    背景 公司一台十一年前的服务器砸到我手中,要重装CentOS7的操作系统. 本着不想进机房, 不想格式化U盘的想法, 想用BMC进行安装系统. 遇到的第一个问题是不知道密码. 询问之前的机器持有人,也 ...

  8. C#使用Elasticsearch入门

    一.Elasticsearch 简介 Elasticsearch 是一个分布式.RESTful 风格的搜索和数据分析引擎,能够解决不断涌现出的各种用例.作为 Elastic Stack 的核心,它集中 ...

  9. net core控制台程序使用依赖注入读取appsettings.json配置文件

    .net 2.1有用,转自https://www.jianshu.com/p/726d1aa2795c 1.项目下添加appsettings.json文件,并将属性-复制到输出目录,设置为如果较新则复 ...

  10. Postfix + Extmail 企业邮件服务器搭建

    ExtMail套件用于提供从浏览器中登录.使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面.它以GPL版权释出,设计初衷是希望设计一个适应当前高速发展的I ...