apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.94k stars 6.74k forks source link

Complex query error #27922

Closed S126gj closed 3 months ago

S126gj commented 1 year ago

my pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.0</version>
    </parent>

  <!-- mysql -->
  <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.31</version>
  </dependency>
<!--sharding-jdbc-->
<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-jdbc-core</artifactId>
    <version>5.4.0</version>
</dependency>
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.3.0</version>
</dependency>
<!-- mybatis-plus -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.3.1</version>
    <exclusions>
        <!-- 解决jsqlparser 依赖版本冲突 -->
        <exclusion>
            <artifactId>jsqlparser</artifactId>
            <groupId>com.github.jsqlparser</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.github.jsqlparser</groupId>
    <artifactId>jsqlparser</artifactId>
    <version>4.2</version>
</dependency>

my yml

spring:
  datasource:
    driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
    url: jdbc:shardingsphere:classpath:sharding/sharding-dev.yaml

# mybatis-plus
mybatis-plus:
  type-aliases-package: com.device.entity
  mapper-locations: classpath*:com/device/**/*.xml
  configuration:
    # 输出日志到控制台
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

sharding-dev.yaml

dataSources:
  ds_0:
    dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/maintenance?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&stringtype=unspecified
    username: root
    password: 123456
    initialSize: 5   #连接池初始化连接数
    minIdle: 3       #连接池最小连接数
    maxActive: 20   #连接池最大连接数
    maxWait: 5000
rules:
  - !SINGLE
    tables:
      - ds_0.*  # 加载该数据源的全部表
    defaultDataSource: ds_0
  - !SHARDING
    tables: # 数据分片规则配置
      box_run: # 逻辑表名称
        actualDataNodes : ds_0.box_run_$->{0..7} # 由数据源名 + 表名组成(参考 Inline 语法规则)
        tableStrategy: # 分表策略,同分库策略
          standard: # 用于单分片键的标准分片场景
            shardingColumn: id # 分片列名称
            shardingAlgorithmName: box_run_inline # 分片算法名称
        keyGenerateStrategy: # 分布式序列策略
          column: id # 自增列名称,缺省表示不使用自增主键生成器
          keyGeneratorName: snowflake # 分布式序列算法名称
    # 分片算法配置
    shardingAlgorithms:
      box_run_inline: # 分片算法名称
        type: INLINE # 分片算法类型
        props: # 分片算法属性配置 t_user_$->{u_id % 8} 表示 t_user 表根据 u_id 模 8,而分成 8 张表,表名称为 t_user_0 到 t_user_7
          algorithm-expression: box_run_$->{id % 8}

    # 分布式序列算法配置
    keyGenerators:
      snowflake: # 分布式序列算法名称
        type: SNOWFLAKE # 分布式序列算法类型
props:
  sql-show: true

mysql table box_run

CREATE TABLE `box_run_0`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_1`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_2`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_3`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_4`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_5`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_6`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

CREATE TABLE `box_run_7`
(
    `id`                   bigint                                                       NOT NULL COMMENT 'id',
    `last_query_time`      datetime                                                    DEFAULT NULL COMMENT '查询时间',
    `box_code`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
    `product_number_begin` decimal(30, 2)                                              DEFAULT '0.00' COMMENT '开始生产数量',
    `product_number`       decimal(30, 2)                                              DEFAULT '0.00' COMMENT '生产数量',
    `avg_speed`            decimal(10, 2)                                              DEFAULT '0.00' COMMENT '平均速率',
    `begin_time`           datetime                                                    DEFAULT NULL COMMENT '开始时间',
    `end_time`             datetime                                                    DEFAULT NULL COMMENT '结束时间',
    `duration`             bigint                                                      DEFAULT '0' COMMENT '时长(分钟)',
    `machine_state`        varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
    `gmt_create`           datetime                                                    DEFAULT NULL COMMENT '创建日期',
    `gmt_modified`         datetime                                                    DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                    `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';

test code

image

queryHistory xml

    <select id="queryHistory" resultType="com.device.system.core.entity.vo.MachineHistoryVO">
        SELECT DATE (begin_time) AS date,
            IFNULL(end_time, NOW()) AS sortEndTime,
            SUM (duration) AS workDuration,
            SUM (CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS energizeDuration,
            SUM (product_number - product_number_begin) AS productNum,
            AVG (avg_speed) AS avgSpeed,
            (case when #{bestSpeed,jdbcType=DOUBLE}!= 0 then AVG(avg_speed) / #{bestSpeed,jdbcType=DOUBLE} else 0 end) AS ep
        FROM (
            SELECT *
            FROM box_run WHERE box_code = #{boxCode,jdbcType=VARCHAR}
            )
        GROUP BY DATE (begin_time)
        ORDER BY begin_time DESC, sortEndTime DESC;
    </select>

the error messge

org.mybatis.spring.MyBatisSystemException
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
    at jdk.proxy2/jdk.proxy2.$Proxy116.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at jdk.proxy2/jdk.proxy2.$Proxy149.queryHistory(Unknown Source)
    at com.device.system.ShardTest.query(ShardTest.java:82)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an error in your SQL syntax: SELECT COUNT(*) FROM (SELECT DATE(begin_time) AS date, IFNULL(end_time, NOW()) AS sortEndTime, SUM(duration) AS workDuration, SUM(CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS energizeDuration, SUM(product_number - product_number_begin) AS productNum, AVG(avg_speed) AS avgSpeed, (CASE WHEN ? != 0 THEN AVG(avg_speed) / ? ELSE 0 END) AS ep FROM (SELECT * FROM box_run WHERE box_code = ?) GROUP BY DATE(begin_time) ORDER BY begin_time DESC, sortEndTime DESC) TOTAL, no viable alternative at input 'SELECTCOUNT(*)FROM(SELECTDATE(begin_time)ASdate,IFNULL(end_time,NOW())ASsortEndTime,SUM(duration)ASworkDuration,SUM(CASEWHENmachine_state!='关机'THENdurationELSE0END)ASenergizeDuration,SUM(product_number-product_number_begin)ASproductNum,AVG(avg_speed)ASavgSpeed,(CASEWHEN?!=0THENAVG(avg_speed)/?ELSE0END)ASepFROM(SELECT*FROMbox_runWHEREbox_code=?)GROUP' at line 1, position 403, near [@95,403:407='GROUP',<292>,1:403]
    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
    at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
    at jdk.proxy2/jdk.proxy2.$Proxy232.prepare(Unknown Source)
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:87)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
    at com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor.willDoQuery(PaginationInnerInterceptor.java:135)
    at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:75)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
    at jdk.proxy2/jdk.proxy2.$Proxy231.query(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
    ... 78 more
Caused by: org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an error in your SQL syntax: SELECT COUNT(*) FROM (SELECT DATE(begin_time) AS date, IFNULL(end_time, NOW()) AS sortEndTime, SUM(duration) AS workDuration, SUM(CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS energizeDuration, SUM(product_number - product_number_begin) AS productNum, AVG(avg_speed) AS avgSpeed, (CASE WHEN ? != 0 THEN AVG(avg_speed) / ? ELSE 0 END) AS ep FROM (SELECT * FROM box_run WHERE box_code = ?) GROUP BY DATE(begin_time) ORDER BY begin_time DESC, sortEndTime DESC) TOTAL, no viable alternative at input 'SELECTCOUNT(*)FROM(SELECTDATE(begin_time)ASdate,IFNULL(end_time,NOW())ASsortEndTime,SUM(duration)ASworkDuration,SUM(CASEWHENmachine_state!='关机'THENdurationELSE0END)ASenergizeDuration,SUM(product_number-product_number_begin)ASproductNum,AVG(avg_speed)ASavgSpeed,(CASEWHEN?!=0THENAVG(avg_speed)/?ELSE0END)ASepFROM(SELECT*FROMbox_runWHEREbox_code=?)GROUP' at line 1, position 403, near [@95,403:407='GROUP',<292>,1:403]
    at org.apache.shardingsphere.sql.parser.core.database.parser.SQLParserExecutor.twoPhaseParse(SQLParserExecutor.java:69)
    at org.apache.shardingsphere.sql.parser.core.database.parser.SQLParserExecutor.parse(SQLParserExecutor.java:48)
    at org.apache.shardingsphere.sql.parser.api.SQLParserEngine.parse(SQLParserEngine.java:47)
    at org.apache.shardingsphere.infra.parser.sql.SQLStatementParserExecutor.parse(SQLStatementParserExecutor.java:46)
    at org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader.load(SQLStatementCacheLoader.java:41)
    at org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader.load(SQLStatementCacheLoader.java:30)
    at com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$3(LocalLoadingCache.java:183)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2685)
    at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2683)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2666)
    at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
    at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:58)
    at org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine.parse(SQLStatementParserEngine.java:47)
    at org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:52)
    at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:199)
    at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:164)
    at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:88)
    at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:327)
    at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
    at jdk.proxy3/jdk.proxy3.$Proxy237.prepareStatement(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:86)
    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
    ... 104 more

There are three test methods, the results are all in the comments, the first query is normal, the second query results mysql has a value, but the query returns null, and the third xml query reports an error

RaigorJiang commented 1 year ago

@S126gj This SQL statement is really complicated, hope some volunteers will try it

zihaoAK47 commented 1 year ago

@S126gj Hi, based on the SQL you defined in XML, it seems that your subquery requires an alias. Incorrect SQL will not be parsed correctly

    SELECT DATE (begin_time) AS date,
        IFNULL(end_time, NOW()) AS sortEndTime,
        SUM (duration) AS workDuration,
        SUM (CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS energizeDuration,
        SUM (product_number - product_number_begin) AS productNum,
        AVG (avg_speed) AS avgSpeed,
        (case when #{bestSpeed,jdbcType=DOUBLE}!= 0 then AVG(avg_speed) / #{bestSpeed,jdbcType=DOUBLE} else 0 end) AS ep
    FROM (
        SELECT *
        FROM box_run WHERE box_code = #{boxCode,jdbcType=VARCHAR}
        )
    GROUP BY DATE (begin_time)
    ORDER BY begin_time DESC, sortEndTime DESC;
S126gj commented 1 year ago

@S126gj您好,根据您在 XML 中定义的 SQL,您的子查询似乎需要别名。错误的SQL将无法被正确解析

    SELECT DATE (begin_time) AS date,
        IFNULL(end_time, NOW()) AS sortEndTime,
        SUM (duration) AS workDuration,
        SUM (CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS energizeDuration,
        SUM (product_number - product_number_begin) AS productNum,
        AVG (avg_speed) AS avgSpeed,
        (case when #{bestSpeed,jdbcType=DOUBLE}!= 0 then AVG(avg_speed) / #{bestSpeed,jdbcType=DOUBLE} else 0 end) AS ep
    FROM (
        SELECT *
        FROM box_run WHERE box_code = #{boxCode,jdbcType=VARCHAR}
        )
    GROUP BY DATE (begin_time)
    ORDER BY begin_time DESC, sortEndTime DESC;

The above statement does not report an error, but the execution of this statement still finds out more than one, and it is not union all, but executed eight times

MachineMonitorDetailVO vo = machineSaleMapper.queryOneMonitor("1681905423199850497");
log.info("vo:{}", JSONUtil.toJsonStr(vo));

queryOneMonitor.xml

<select id="queryOneMonitor" resultType="com.device.system.core.entity.vo.MachineMonitorDetailVO">
        SELECT sale.id                 machineSaleId,
               machine.id              machineId,
               machine.type            machineType,
               machine.`name`          machineName,
               machine.img_path        machineImg,
               customer.id             customerId,
               customer.`name`         customerName,
               customer.simple_name    customerSimpleName,
               customer.contacts_name  customerContactName,
               customer.contacts_phone customerContactsPhone,
               dealer.id               dealerId,
               dealer.`name`           dealerName,
               dealer.simple_name      dealerSimpleName,
               sale.province           installProvince,
               sale.city               installCity,
               sale.region             installRegion,
               sale.address            installAddress,
               (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0)
                                                   FROM box_run
                                                   WHERE box_code = sale.box_code
                                                     AND end_time IS NULL
                                                     AND machine_state != '关机')
        FROM box_run
        WHERE box_code = sale.box_code
          AND machine_state != '关机') totalWorkDuration
            , (
        SELECT IFNULL(SUM (product_number - product_number_begin), 0)
        FROM box_run
        WHERE box_code = sale.box_code) totalProductNum
            , (
        SELECT IFNULL(SUM (avg_speed) / COUNT (*), 0)
        FROM box_run
        WHERE box_code = sale.box_code
          AND machine_state != '关机') totalAvgSpeed
        FROM sys_machine_sale as sale
            LEFT JOIN sys_machine machine
        ON machine.id = sale.machine_id
            LEFT JOIN sys_customer customer ON customer.id = sale.customer_id
            LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id
        where sale.id = #{machineSaleId,jdbcType=VARCHAR}
    </select>
parse the finished SQL: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11'
JDBC Connection [HikariProxyConnection@1976652636 wrapping org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection@509b4a57] will not be managed by Spring
==>  Preparing: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11'
==> Parameters: 1681905423199850497(String)
2023-08-07T09:12:53.850+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Logic SQL: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11'
2023-08-07T09:12:53.850+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_0 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_0 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_0 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.850+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_1 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_1 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_1 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.850+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_2 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_2 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_2 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.851+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_3 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_3 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_3 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.851+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_4 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_4 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_4 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.851+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_5 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_5 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_5 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.851+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_6 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_6 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_6 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
2023-08-07T09:12:53.851+08:00  INFO 8639 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds_0 ::: SELECT sale.id machineSaleId, machine.id machineId, machine.type machineType, machine.`name` machineName, machine.img_path machineImg, customer.id customerId, customer.`name` customerName, customer.simple_name customerSimpleName, customer.contacts_name customerContactName, customer.contacts_phone customerContactsPhone, dealer.id dealerId, dealer.`name` dealerName, dealer.simple_name dealerSimpleName, sale.province installProvince, sale.city installCity, sale.region installRegion, sale.address installAddress, (SELECT IFNULL(SUM(duration), 0) + (SELECT IFNULL(SUM(TIMESTAMPDIFF(MINUTE, begin_time, NOW())), 0) FROM box_run WHERE box_code = sale.box_code AND end_time IS NULL AND machine_state != '关机') FROM box_run_7 WHERE box_code = sale.box_code AND machine_state != '关机') totalWorkDuration, (SELECT IFNULL(SUM(product_number - product_number_begin), 0) FROM box_run_7 WHERE box_code = sale.box_code) totalProductNum, (SELECT IFNULL(SUM(avg_speed) / COUNT(*), 0) FROM box_run_7 WHERE box_code = sale.box_code AND machine_state != '关机') totalAvgSpeed FROM sys_machine_sale AS sale LEFT JOIN sys_machine machine ON machine.id = sale.machine_id AND machine.tenant_id = '11' LEFT JOIN sys_customer customer ON customer.id = sale.customer_id AND customer.tenant_id = '11' LEFT JOIN sys_dealer dealer ON dealer.id = sale.dealer_id AND dealer.tenant_id = '11' WHERE sale.id = ? AND sale.tenant_id = '11' ::: [1681905423199850497]
<==    Columns: machineSaleId, machineId, machineType, machineName, machineImg, customerId, customerName, customerSimpleName, customerContactName, customerContactsPhone, dealerId, dealerName, dealerSimpleName, installProvince, installCity, installRegion, installAddress, totalWorkDuration, totalProductNum, totalAvgSpeed
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 78, -6468.00, -3.138462
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 2264, -4031.00, -13.447195
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==        Row: 1681905423199850497, 1681901730995949570, ZZ-1, 组装机, null, 1681903041590120449, 浙江飞虹, 飞虹, 顾, 1546210110, 1676457335121301505, 测试12, 测试, 西藏自治区, 那曲市, 申扎县, , 0, 0.00, 0.000000
<==      Total: 8
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@570a150b]

org.mybatis.spring.MyBatisSystemException
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
    at jdk.proxy2/jdk.proxy2.$Proxy116.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:89)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at jdk.proxy2/jdk.proxy2.$Proxy147.queryOneMonitor(Unknown Source)
    at com.device.system.ShardTest.query(ShardTest.java:91)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 8
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:80)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
    ... 77 more
S126gj commented 1 year ago

@S126gj This SQL statement is really complicated, hope some volunteers will try it

Can someone answer my question

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

RaigorJiang commented 1 year ago

Hi @S126gj According to the exception you updated last time, it may be that the SQL and data do not match?

Expected one result (or null) to be returned by selectOne(), but found: 8

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.