xueshiji commented on issue #9569:
URL: https://github.com/apache/shardingsphere/issues/9569#issuecomment-790206530
@yu199195
**1.the complete Logic SQL and Actual SQL**
Logic:`select * from ( select row_.*, rownum rownum_ from ( select
loginfo0_.ZCTYPE as col_0_0_, loginfo0_.BIZCODE as col_1_0_, loginfo0_.GID as
col_2_0_, loginfo0_.JID as col_3_0_, loginfo0_.KEY as col_4_0_,
loginfo0_.OPERATOR as col_5_0_, loginfo0_.DJTSZT as col_6_0_, loginfo0_.DJTSSJ
as col_7_0_ from DB.tablename loginfo0_ where loginfo0_.KEY>-1 ) row_ where
rownum <= ?) where rownum_ > ? ::: [3, 2]`
Actual :`select * from ( select row_.*, rownum rownum_ from ( select
loginfo0_.ZCTYPE as col_0_0_, loginfo0_.BIZCODE as col_1_0_, loginfo0_.GID as
col_2_0_, loginfo0_.JID as col_3_0_, loginfo0_.KEY as col_4_0_,
loginfo0_.OPERATOR as col_5_0_, loginfo0_.DJTSZT as col_6_0_, loginfo0_.DJTSSJ
as col_7_0_ from tablename_44 loginfo0_ where loginfo0_.KEY>-1 ) row_ where
rownum <= ?) where rownum_ > ? ::: [3, 2]
`
**2.the sharding-config:**
`@Bean(name = "shardingDatasource")
DataSource getDataSourceBean(@Qualifier("dataSource") DataSource
dataSource1) {
Map<String, DataSource> dataSourceMap = new HashMap<>();
dataSourceMap.put("ds0", dataSource1);
ShardingTableRuleConfiguration orderTableRuleConfig = new
ShardingTableRuleConfiguration("tablename", getActualDataNodes());
orderTableRuleConfig.setTableShardingStrategy(new
StandardShardingStrategyConfiguration("key", "tableShardingAlgorithm"));
ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(orderTableRuleConfig);
Properties tableShardingAlgorithmrProps = new Properties();
tableShardingAlgorithmrProps.setProperty("algorithm-expression",
"tablename_${key}");
tableShardingAlgorithmrProps.setProperty("allow-range-query-with-inline-sharding",
"true");
shardingRuleConfig.getShardingAlgorithms().put("tableShardingAlgorithm", new
ShardingSphereAlgorithmConfiguration("INLINE", tableShardingAlgorithmrProps));
Properties properties = new Properties();
properties.setProperty("sql-show", "true");
DataSource dataSource = null;
try {
dataSource =
ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
Collections.singleton(shardingRuleConfig), properties);
} catch (Exception throwables) {
log.error(throwables.toString());
}
return dataSource;
}`
----------------------------------------------------------------
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:
[email protected]