You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/03/30 09:58:59 UTC

[GitHub] [shardingsphere] RelaxBin edited a comment on issue #9873: how to ignore table name case in sharding5.x

RelaxBin edited a comment on issue #9873:
URL: https://github.com/apache/shardingsphere/issues/9873#issuecomment-810086005


   > Hi @RelaxBin ,
   > 
   > Could you provide more details about this exception? I wanna locate where this exception came from, and in my head, ShardingSphere is case-insensitive for tables.
   
   First, The orm framework I use is MybatisPlus3.0.6.   
   The PO is StudentInfoPO
   ![image](https://user-images.githubusercontent.com/17397623/112970868-3cb16700-9181-11eb-82f5-a5c9e07664c8.png)
   
   Mapper:
   ![image](https://user-images.githubusercontent.com/17397623/112970920-489d2900-9181-11eb-9d21-0a2ac751cd4e.png)
   
   
   
   Then , In my unit test, 
   ![image](https://user-images.githubusercontent.com/17397623/112970978-55218180-9181-11eb-92e4-a7ecaa910196.png)
   
   When the table name is lowercase, that is ok.
   
   But when I execute the unit test, the following exception is thrown:
   
   SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e1237ab] was not registered for synchronization because synchronization is not active
   JDBC Connection [org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection@42ed89da] will not be managed by Spring
   ==>  Preparing: SELECT student_name FROM STUDENT_INFO 
   ==> Parameters: 
   Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e1237ab]
   
   org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
   ### Error querying database.  Cause: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not route tables for `[STUDENT_INFO]`, please make sure the tables are in same schema.
   ### The error may exist in com/lemon/shardingsphere/mapper/StudentInfoMapper.java (best guess)
   ### The error may involve defaultParameterMap
   ### The error occurred while setting parameters
   ### SQL: SELECT  student_name  FROM STUDENT_INFO
   ### Cause: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not route tables for `[STUDENT_INFO]`, please make sure the tables are in same schema.
   
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
   	at com.sun.proxy.$Proxy80.selectList(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
   	at com.baomidou.mybatisplus.core.override.PageMapperMethod.executeForMany(PageMapperMethod.java:173)
   	at com.baomidou.mybatisplus.core.override.PageMapperMethod.execute(PageMapperMethod.java:86)
   	at com.baomidou.mybatisplus.core.override.PageMapperProxy.invoke(PageMapperProxy.java:64)
   	at com.sun.proxy.$Proxy89.selectList(Unknown Source)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
   	at com.sun.proxy.$Proxy90.selectList(Unknown Source)
   	at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.list(ServiceImpl.java:291)
   	at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:279)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)
   	at com.sun.proxy.$Proxy91.list(Unknown Source)
   	at com.lemon.shardingsphere.StuedntInfoTest.testQueryStudentList(StuedntInfoTest.java:24)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
   	at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
   	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
   	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
   	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
   	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
   	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
   Caused by: org.apache.ibatis.exceptions.PersistenceException: 
   ### Error querying database.  Cause: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not route tables for `[STUDENT_INFO]`, please make sure the tables are in same schema.
   ### The error may exist in com/lemon/shardingsphere/mapper/StudentInfoMapper.java (best guess)
   ### The error may involve defaultParameterMap
   ### The error occurred while setting parameters
   ### SQL: SELECT  student_name  FROM STUDENT_INFO
   ### Cause: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not route tables for `[STUDENT_INFO]`, please make sure the tables are in same schema.
   	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
   	... 57 more
   Caused by: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not route tables for `[STUDENT_INFO]`, please make sure the tables are in same schema.
   	at org.apache.shardingsphere.sharding.route.engine.type.unconfigured.ShardingUnconfiguredTablesRoutingEngine.route(ShardingUnconfiguredTablesRoutingEngine.java:55)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:70)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:55)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:59)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:57)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:266)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:198)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
   	at com.sun.proxy.$Proxy109.execute(Unknown Source)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
   	at com.sun.proxy.$Proxy108.query(Unknown Source)
   	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
   	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)
   	... 63 more
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org