NutzCN Logo
问答 求教,调用sharding JDBC时别名产生的异常解决
发布于 1842天前 作者 baocj 7154 次浏览 复制 上一个帖子 下一个帖子
标签:
select count(1) from (SELECT
CONCAT(p.id,"") id,
-- p.id,
p.bar_project_no,
p.bar_project_name,
p.bar_project_image,
CONCAT( city.city_fullname, '-', ad.ad_fullname ) AS bar_project_areaname,
p.bar_project_addr,
dict_type.childName AS bar_project_type,
dict_trade.childName AS bar_project_trade,
b.bar_building_count,
b.bar_building_areacount
FROM
bar_project p
LEFT JOIN sys_citycode city ON city.opBy = p.city_code
AND city.delFlag = 0
LEFT JOIN sys_adcode ad ON ad.ad_code = p.ad_code
LEFT JOIN (
SELECT
p.id AS parentId,
p.CODE AS parentCode,
p.`name` AS parentName,
d.id AS childId,
d.`code` AS childCode,
d.`name` AS childName
FROM
sys_dict p,
sys_dict d
WHERE
p.id = d.parentId
AND p.delFlag = 0
AND d.delFlag = 0
ORDER BY
p.id,
d.`code` ASC
) dict_type ON dict_type.parentCode = 'bar_project_type'
AND dict_type.childCode = p.bar_project_type
LEFT JOIN (
SELECT
p.id AS parentId,
p.CODE AS parentCode,
p.`name` AS parentName,
d.id AS childId,
d.`code` AS childCode,
d.`name` AS childName
FROM
sys_dict p,
sys_dict d
WHERE
p.id = d.parentId
AND p.delFlag = 0
AND d.delFlag = 0
ORDER BY
p.id,
d.`code` ASC
) dict_trade ON dict_trade.parentCode = 'bar_project_trade'
AND dict_trade.childCode = p.bar_project_trade
LEFT JOIN (
SELECT
b.bar_project_id,
IFNULL( COUNT( b.id ), 0 ) bar_building_count,
IFNULL( SUM( b.bar_building_area ), 0 ) bar_building_areacount
FROM
bar_building b
GROUP BY
b.bar_project_id
) b ON b.bar_project_id = p.id)as _nutz_tmp_5gt3sckvr8gklrnsjdrl6dqsu4

调用sharding JDBC时,这个产生的别名导致异常

Caused by: java.lang.IllegalStateException: Must have sharding column with subquery.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:444)
	at org.apache.shardingsphere.core.route.router.sharding.ParsingSQLRouter.checkSubqueryShardingValues(ParsingSQLRouter.java:111)
	at org.apache.shardingsphere.core.route.router.sharding.ParsingSQLRouter.route(ParsingSQLRouter.java:75)
	at org.apache.shardingsphere.core.route.StatementRoutingEngine.route(StatementRoutingEngine.java:56)
	at org.apache.shardingsphere.core.SimpleQueryShardingEngine.route(SimpleQueryShardingEngine.java:60)
	at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:86)
	at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:70)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingStatement.shard(ShardingStatement.java:256)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingStatement.executeQuery(ShardingStatement.java:91)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:250)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:59)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:65)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:63)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:138)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:163)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:130)
	... 40 more

要怎么解决

1 回复
添加回复
请先登陆
回到顶部