Closed dongoewang closed 10 months ago
如果你设了bindingTables,他会检查actualDataNodes里面是否有对应的绑定表,你必须以表达式配置actualDataNodes,或者重写InlineExpressionParser
如果你设了bindingTables,他会检查actualDataNodes里面是否有对应的绑定表,你必须以表达式配置actualDataNodes,或者重写InlineExpressionParser
thanks for your answer。where does the Official documents explain?
i modified the sql ,then program can run。but i don't know this configuration is right or wrong previous ql:
SELECT COUNT(*) FROM kq_employee_clock_record a LEFT JOIN hr_employee e ON a.employee_id = e.id LEFT JOIN hr_organ_position p ON e.post_id = p.id LEFT JOIN kq_attendance_daily kad ON kad.id = ( SELECT id FROM kq_attendance_daily WHERE delete_flag = 0 AND employee_id = a.employee_id AND attendance_date = date_format( a.clock_time, '%Y-%m-%d' ) LIMIT 1 ) WHERE a.type = 2 AND a.flow_flag = 1 AND ( kad.id IS NULL OR e.is_overtime != '1' OR kad.work_type != '0' ) AND (( a.attendance_date >= ? AND a.attendance_date <= ?))
present sql :
SELECT COUNT(*) FROM kq_employee_clock_record a LEFT JOIN hr_employee e ON a.employee_id = e.id LEFT JOIN hr_organ_position p ON e.post_id = p.id LEFT JOIN kq_attendance_daily kad ON kad.id = ( SELECT id FROM kq_attendance_daily WHERE delete_flag = 0 AND employee_id = a.employee_id AND attendance_date = date_format( a.clock_time, '%Y-%m-%d' ) LIMIT 1 ) WHERE a.type = 2 AND a.flow_flag = 1 AND ( kad.id IS NULL OR e.is_overtime != '1' OR kad.work_type != '0' ) AND (( a.attendance_date >= ? AND a.attendance_date <= ?)) AND (( kad.attendance_date >= ? AND kad.attendance_date <= ?))
如果你设了bindingTables,他会检查actualDataNodes里面是否有对应的绑定表,你必须以表达式配置actualDataNodes,或者重写InlineExpressionParser
A great expert
overwrite InlineExpressionParser
singlemonkey had helped me to solve this problem ,so i closed this issue.
Table Definition table 1 CREATE TABLE
kq_attendance_daily_202401
(id
bigint NOT NULL AUTO_INCREMENT COMMENT 'id',organ_id
bigint NULL DEFAULT NULL COMMENT '项目id',employee_id
bigint NOT NULL COMMENT '员工ID',dept_id
bigint NULL DEFAULT NULL COMMENT '部门id',post_id
bigint NULL DEFAULT NULL COMMENT '职位id 迁移用',attendance_plan_id
bigint NULL DEFAULT NULL COMMENT '考勤方案ID',attendance_date
date NOT NULL COMMENT '日期 yyyy-mm-dd',table 2 CREATE TABLE
kq_employee_clock_record_202401
(id
bigint NOT NULL AUTO_INCREMENT,attendance_date
date NULL DEFAULT NULL PRIMARY KEY (id
) USING BTREE ) ; CREATE TABLEkq_employee_clock_record_202402
(id
bigint NOT NULL AUTO_INCREMENT,attendance_date
date NULL DEFAULT NULL PRIMARY KEY (id
) USING BTREE ) ; sharding-config.yaml mode: type: Cluster repository: type: ZooKeeper props: namespace: generator_demo server-lists: localhost:2181java file:ClockRecordAutoShardingAlgorithm @Log4j2 @Data public class ClockRecordAutoShardingAlgorithm extends ShardingCommonAlgorithm implements StandardShardingAlgorithm, ShardingAutoTableAlgorithm {
runtime error information org.springframework.dao.DataIntegrityViolationException:
Error querying database. Cause: java.sql.SQLException: Actual table
datasource.kq_employee_clock_record_202401
is not in table rule configuration.