描述:

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. [转帖]编译安装goofys挂载Scaleway免费75G对象存储

    日常•2022年5月29日   goofys编译 goofys是一个开源的使用Go编写的s3存储桶挂载工具,主打高性能.由于使用Go编写,没有用到什么特别的依赖,自己编译也很容易.截止2022.5.2 ...

  2. [转帖]SSL数字证书分类DV/OV/EV

    SSL证书的分类主要是通过下面两个维度进行分类: 1.根据验证模式分类 根据CA机构对申请者的身份审核范围分为:DV证书.OV证书.EV证书. 1.1.DV证书(域名证书) DV(Domain Val ...

  3. [转帖]Shell中常用的date时间命令

    常用FORMAT %Y  YYYY格式的年份(Year) %m  mm格式的月份(),01-12 %d   dd格式的日期(day of month),01-31 %H   HH格式的小时数(),00 ...

  4. [转帖]龙芯3A5000评测 国产自主指令集架构实战

      https://tieba.baidu.com/p/8297036384?pid=147031768904&cid=#147031768904 芯片,是世界一大难题,很多人难以想象电子硬件 ...

  5. [转帖]Native Memory Tracking 详解(3):追踪区域分析(二)

    https://www.modb.pro/db/539804 上篇文章 Native Memory Tracking 详解(2):追踪区域分析(一) 中,分享了NMT追踪区域的部分内存类型--Java ...

  6. 【k哥爬虫普法】程序员183并发爬取官方网站,直接获刑3年?

    我国目前并未出台专门针对网络爬虫技术的法律规范,但在司法实践中,相关判决已屡见不鲜,K 哥特设了"K哥爬虫普法"专栏,本栏目通过对真实案例的分析,旨在提高广大爬虫工程师的法律意识, ...

  7. 微信小程序-Storage

    官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html ?> Sto ...

  8. 数据挖掘机器学习[七]---2021研究生数学建模B题空气质量预报二次建模求解过程:基于Stacking机器学习混合模型的空气质量预测{含码源+pdf文章}

    相关文章: 特征工程详解及实战项目[参考] 数据挖掘---汽车车交易价格预测[一](测评指标:EDA) 数据挖掘机器学习---汽车交易价格预测详细版本[二]{EDA-数据探索性分析} 数据挖掘机器学习 ...

  9. Gin 中间件

    中间件 在Gin框架中,中间件(Middleware)指的是可以拦截http请求-响应生命周期的特殊函数,在请求-响应生命周期中可以注册多个中间件,每个中间件执行不同的功能,一个中间执行完再轮到下一个 ...

  10. MongoDB 7.0 搭建 Sharding 副本集群

    本文是在ubuntu 22.03 系统版本上部署的,最低支持mongodb-6.0.4以上,所以这里安装mongodb7.0 1 安装mongo 安装方式有多种,本人是使用的第一种方式,时间也就20分 ...