出现版本:
select * from (
select id from test
) as a GROUP BY a.id
这个语句会报错
但是如果是这个语句就不会了:
select * from (
select id from test
) as a GROUP BY id
后面发现这个出现在使用 这个数据库框架的时候: shardingsphere
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
shardingsphere读写分离配置:
shardingsphere:
datasource:
names: master,slave0
master:
type: com.thit.web.config.MyDruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
#配置基本属性
url: jdbc:mysql://127.0.0.1:33016/inter_server_pro?serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: admin
password: admin
slave0:
type: com.thit.web.config.MyDruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
#配置基本属性
url: jdbc:mysql://127.0.0.1:33016/inter_server_pro?serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: admin
password: admin
masterslave:
name: ms
master-data-source-name: master
slave-data-source-names: master,slave0
props:
sql:
show: true
Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement. Cause: java.lang.IllegalStateException: Can not find owner from table.
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
at sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor.intercept(PaginationInterceptor.java:156)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy388.prepare(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 82 common frames omitted
如果不使用 shardingsphere框架是不会的。但是个人认为是 mybatis-plus 问题。
你认为是mp的问题,那你应该找出到底是什么问题才对,talk is cheap show me the code
。。。
------------------ 原始邮件 ------------------
发件人: "miemieYaho"<[email protected]>;
发送时间: 2020年6月9日(星期二) 下午3:12
收件人: "baomidou/mybatis-plus"<[email protected]>;
抄送: "小马过河"<[email protected]>; "Author"<[email protected]>;
主题: Re: [baomidou/mybatis-plus] 出现 Can not find owner from table报错。和shardingsphere一起使用的时候。 (#2585)
你认为是mp的问题,那你应该找出到底是什么问题才对,talk is cheap show me the code
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
我也不是没有解决方案。我就觉得你们的框架不错。给你们提的问题。报错信息给你们了。我认为你们是能重现的。
------------------ 原始邮件 ------------------
发件人: "miemieYaho"<[email protected]>;
发送时间: 2020年6月9日(星期二) 下午3:12
收件人: "baomidou/mybatis-plus"<[email protected]>;
抄送: "小马过河"<[email protected]>;"Author"<[email protected]>;
主题: Re: [baomidou/mybatis-plus] 出现 Can not find owner from table报错。和shardingsphere一起使用的时候。 (#2585)
你认为是mp的问题,那你应该找出到底是什么问题才对,talk is cheap show me the code
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
那你写个demo看看
好吧
同样出现了和你一样的问题
我也出现同样的问题了,麻烦问下楼主是怎么解决的
同问,什么原因导致的。
同问,什么原因导致的。
shardingsphere的bug,去掉shardingsphere
这个看起来是的确是 shardingsphere 内部使用的 sql 解析器有问题, 异常是由org.apache.shardingsphere.sql.parser.binder.segment.select.projection.engine.ProjectionsContextEngine.java:197 find 方法中抛出的, 问题的关键在于 org.apache.shardingsphere.sql.parser.SQLParserEngine.java:57 parse 方法中对 sql 的解析是有问题的. 相关的 issue
同样出现了一样的问题,这个应该是shardingsphere的问题,因为单独用是没有问题的