only sharding db, use pagehelper, report error: Must have sharding column with subquery
sharding version: 4.0.0-RC1 Only by business sharding databases, use pagehelper to Paging sql. Original sql: select DISTINCT m.id, m.receipt_no, m.customs_no, m.receipt_type, m.owner_no, m.owner_name, m.tenant_id, m.org_no, m.distribute_no, m.warehouse_no from ib_receipt_task_m m LEFT JOIN ib_receipt_task_d as d on d.receipt_no = m.receipt_no and d.tenant_id = m.tenant_id and d.warehouse_no = m.warehouse_no where m.is_delete = 0 AND m.tenant_id = '123456' AND m.warehouse_no = '123456' AND (m.receipt_no IN ('123','456') OR m.source_no IN ('1','2')) AND m.status = 0 order by m.id desc
both table ib_receipt_task_m and table ib_receipt_task_d are in same database, Error reporting after execution:
com.jclps.jwms.service.inbound.impl.asn.AsnService.getReceiptTaskPageList():659 - 分页查询异常!异常信息:【nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalStateException: Must have sharding column with subquery.
### The error may exist in file [E:\workspace\jwms_alone\jwms\dao\target\classes\mapper\inbound\mapper\ReceiptTaskMMapper.xml]
### The error may involve com.jclps.jwms.dao.inbound.ReceiptTaskMDao.findPageListByDataAccess-Inline
### The error occurred while setting parameters
### Cause: java.lang.IllegalStateException: Must have sharding column with subquery.】
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalStateException: Must have sharding column with subquery.
### The error may exist in file [E:\workspace\jwms_alone\jwms\dao\target\classes\mapper\inbound\mapper\ReceiptTaskMMapper.xml]
### The error may involve com.jclps.jwms.dao.inbound.ReceiptTaskMDao.findPageListByDataAccess-Inline
### The error occurred while setting parameters
### Cause: java.lang.IllegalStateException: Must have sharding column with subquery.
which column is the databases sharding key ?
which column is the databases sharding key ?
i have no column as sharding key. each database has different table name , i Force routing in my configuration Here is part of my configuration: spring.shardingsphere.sharding.tables.au_data_rule.actual-data-nodes=center.au_data_rule spring.shardingsphere.sharding.tables.au_module.actual-data-nodes=center.au_module spring.shardingsphere.sharding.tables.ib_book_task_d.actual-data-nodes=inbound.ib_book_task_d spring.shardingsphere.sharding.tables.ib_book_task_m.actual-data-nodes=inbound.ib_book_task_m spring.shardingsphere.sharding.tables.b2b_locate_batch.actual-data-nodes=outbound.b2b_locate_batch spring.shardingsphere.sharding.tables.b2b_locate_d.actual-data-nodes=outbound.b2b_locate_d
Oh... what is your database-strategy,table-strategy ?
We are doing the subquery now, so I just pending this issue after we finish the subquery.
We are doing the subquery now, so I just pending this issue after we finish the subquery.
pagehelper use subquery , when i upgrade to 4.0.0-release, this exception is not reported, but the sql find wrong route(default route) ,this is Not expected.
sql:
select count(1) count from (select DISTINCT
m.id,
m.receipt_no,
m.customs_no,
m.receipt_type,
m.owner_no,
m.owner_name,
m.supplier_no,
m.supplier_name,
m.order_time,
m.source_no,
m.source,
m.carrier_no,
m.carrier_name,
m.print_times,
m.status,
m.remark,
m.tenant_id,
m.org_no,
m.distribute_no,
m.warehouse_no,
m.create_time,
m.update_time,
m.create_user,
m.update_user,
m.is_delete,
m.total_sku_qty,
m.total_sku_sort,
m.version,
m.bill_type,
m.is_cross_docking,
m.order_no,
m.order_amount,
m.isv_order_no,
m.isv_source_no,
m.loadteam_no,
m.grade
from ib_receipt_task_m m left join ib_receipt_task_d d
on m.receipt_no = d.receipt_no
and m.warehouse_no = d.warehouse_no
and m.tenant_id = d.tenant_id
where m.is_delete = 0
AND m.tenant_id = ?
AND m.warehouse_no = ?
and m.create_time >= CONCAT(?,' 00:00:00')
and m.create_time < CONCAT(?,' 23:59:59')
and m.receipt_type = ?
order by m.id desc ) t
We are doing the subquery now, so I just pending this issue after we finish the subquery.
Has the problem been solved?
We are doing the subquery now, so I just pending this issue after we finish the subquery.
pagehelper use subquery , when i upgrade to 4.0.0-release, this exception is not reported, but the sql find wrong route(default route) ,this is Not expected. sql: select count(1) count from (select DISTINCT m.id, m.receipt_no, m.customs_no, m.receipt_type, m.owner_no, m.owner_name, m.supplier_no, m.supplier_name, m.order_time, m.source_no, m.source, m.carrier_no, m.carrier_name, m.print_times, m.status, m.remark, m.tenant_id, m.org_no, m.distribute_no, m.warehouse_no, m.create_time, m.update_time, m.create_user, m.update_user, m.is_delete, m.total_sku_qty, m.total_sku_sort, m.version, m.bill_type, m.is_cross_docking, m.order_no, m.order_amount, m.isv_order_no, m.isv_source_no, m.loadteam_no, m.grade from ib_receipt_task_m m left join ib_receipt_task_d d on m.receipt_no = d.receipt_no and m.warehouse_no = d.warehouse_no and m.tenant_id = d.tenant_id where m.is_delete = 0 AND m.tenant_id = ? AND m.warehouse_no = ? and m.create_time >= CONCAT(?,' 00:00:00') and m.create_time < CONCAT(?,' 23:59:59') and m.receipt_type = ? order by m.id desc ) t
Has the problem been solved?
The 5.0.0-beta version supports federation engine which can process subquery, please try it, thank you.