You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "ChinkenEight (via GitHub)" <gi...@apache.org> on 2023/10/16 09:38:43 UTC
[I] sub database select count(0) t_user SQL statement error [shardingsphere]
ChinkenEight opened a new issue, #28772:
URL: https://github.com/apache/shardingsphere/issues/28772
## Bug Report
### Which version of ShardingSphere did you use?
shardingsphere-jdbc-core-spring-boot-starter 5.2.0
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
@Select({"select count(0) from t_user "})
int selectByUserId1();
### Actual behavior
## Error querying database. Cause: java.lang.NullPointerException
### The error may exist in com/atguigu/shargingjdbcdemo/mapper/UserMapper.java (best guess)
### The error may involve com.atguigu.shargingjdbcdemo.mapper.UserMapper.selectByUserId1
### The error occurred while handling results
### SQL: select count(0) from t_user
### Cause: java.lang.NullPointerException
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
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:426)
... 71 more
Caused by: java.lang.NullPointerException
at org.apache.shardingsphere.sharding.merge.dql.groupby.GroupByMemoryMergedResult.getValueCaseSensitiveFromTables(GroupByMemoryMergedResult.java:135)
at org.apache.shardingsphere.sharding.merge.dql.groupby.GroupByMemoryMergedResult.getValueCaseSensitive(GroupByMemoryMergedResult.java:125)
at org.apache.shardingsphere.sharding.merge.dql.groupby.GroupByMemoryMergedResult.init(GroupByMemoryMergedResult.java:73)
at org.apache.shardingsphere.sharding.merge.dql.groupby.GroupByMemoryMergedResult.init(GroupByMemoryMergedResult.java:53)
at org.apache.shardingsphere.infra.merge.result.impl.memory.MemoryMergedResult.<init>(MemoryMergedResult.java:51)
at org.apache.shardingsphere.sharding.merge.dql.groupby.GroupByMemoryMergedResult.<init>(GroupByMemoryMergedResult.java:56)
at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.getGroupByMergedResult(ShardingDQLResultMerger.java:118)
at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.build(ShardingDQLResultMerger.java:88)
at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.merge(ShardingDQLResultMerger.java:66)
at org.apache.shardingsphere.infra.merge.MergeEngine.executeMerge(MergeEngine.java:82)
at org.apache.shardingsphere.infra.merge.MergeEngine.merge(MergeEngine.java:71)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.mergeQuery(ShardingSpherePreparedStatement.java:520)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.getResultSet(ShardingSpherePreparedStatement.java:462)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getFirstResultSet(DefaultResultSetHandler.java:237)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:187)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:163)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
### Reason analyze (If you can)
i dont know
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
application.properties
spring.application.name=sharging-jdbc-demo
spring.profiles.active=dev
spring.shardingsphere.props.sql-show=true
spring.shardingsphere.datasource.db505.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.db505.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.shardingsphere.datasource.db505.url=jdbc:oracle:thin:@localhost:1521:XE
spring.shardingsphere.datasource.db505.username=
spring.shardingsphere.datasource.db505.password=
spring.shardingsphere.datasource.db506.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.db506.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.shardingsphere.datasource.db506.url=jdbc:oracle:thin:@localhost:1521:XE
spring.shardingsphere.datasource.db506.username=
spring.shardingsphere.datasource.db506.password=
spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=db$->{505..506}.t_user
spring.shardingsphere.rules.sharding.tables.t_user.database-strategy.standard.sharding-column=user_id
spring.shardingsphere.rules.sharding.tables.t_user.database-strategy.standard.sharding-algorithm-name=alg_mod
spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=db$->{505..506}.t_order_item
spring.shardingsphere.rules.sharding.tables.t_order_item.database-strategy.standard.sharding-column=user_id
spring.shardingsphere.rules.sharding.tables.t_order_item.database-strategy.standard.sharding-algorithm-name=alg_mod
spring.shardingsphere.rules.sharding.sharding-algorithms.alg_mod.type=INLINE
spring.shardingsphere.rules.sharding.sharding-algorithms.alg_mod.props.algorithm-expression=db$->{user_id.substring(0,3)}
spring.shardingsphere.rules.sharding.broadcast-tables[0]=t_order,t_dict



### Example codes for reproduce this issue (such as a github link).
Table t_user sub database
select count(0) t_user SQL statement error
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] sub database select count(0) from t_user SQL statement error [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #28772: sub database select count(0) from t_user SQL statement error
URL: https://github.com/apache/shardingsphere/issues/28772
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] sub database select count(0) from t_user SQL statement error [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #28772:
URL: https://github.com/apache/shardingsphere/issues/28772#issuecomment-1779060357
Hi @ChinkenEight , can you try the latest version 5.4.1?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] sub database select count(0) from t_user SQL statement error [shardingsphere]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #28772:
URL: https://github.com/apache/shardingsphere/issues/28772#issuecomment-1826051049
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org