Closed S126gj closed 3 months ago
@S126gj This SQL statement is really complicated, hope some volunteers will try it
@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您好,根据您在 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 This SQL statement is really complicated, hope some volunteers will try it
Can someone answer my question
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
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
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
my pom.xml
my yml
sharding-dev.yaml
mysql table box_run
test code
queryHistory xml
the error messge
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