使用环境:
springboot2.7
shardingsphere-starter5.1.2
mybatis-starter2.3.0
mybatis-plus-starter3.5.3.1
场景、问题:
使用分表字段(按日分表)查询,查询涉及到多个分表,报错;如果查询只涉及分表的1张表就不会报错并能正确返回结果
报错信息:
2023-05-31 13:58:08.656 [TID: N/A] [http-nio-7010-exec-1] INFO ShardingSphere-SQL -Logic SQL: select
o.*
from
log_operation o
where
o.operation_date between ? and ?
order by o.id desc
2023-05-31 13:58:08.657 [TID: N/A] [http-nio-7010-exec-1] INFO ShardingSphere-SQL -SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
2023-05-31 13:58:08.657 [TID: N/A] [http-nio-7010-exec-1] INFO ShardingSphere-SQL -Actual SQL: db0 ::: select
o.*
, o.id AS ORDER_BY_DERIVED_0 from
log_operation_20230529 o
where
o.operation_date between ? and ?
order by o.id desc ::: [2023-05-29 00:00:00.0, 2023-05-30 23:00:00.0]
2023-05-31 13:58:08.658 [TID: N/A] [http-nio-7010-exec-1] INFO ShardingSphere-SQL -Actual SQL: db0 ::: select
o.*
, o.id AS ORDER_BY_DERIVED_0 from
log_operation_20230530 o
where
o.operation_date between ? and ?
order by o.id desc ::: [2023-05-29 00:00:00.0, 2023-05-30 23:00:00.0]
2023-05-31 13:58:08.801 [TID: N/A] [http-nio-7010-exec-1] ERROR com.cmit.base.ext.error.GlobalExceptionHandler -服务端异常 nested exception is org.apache.ibatis.exceptions.PersistenceException: