cherrylzhao commented on a change in pull request #122: Add a broadcast-table
example for sharding-jdbc
URL:
https://github.com/apache/incubator-shardingsphere-example/pull/122#discussion_r273356936
##########
File path:
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesAndTablesConfigurationPrecise.java
##########
@@ -41,19 +41,22 @@ public DataSource getDataSource() throws SQLException {
shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
shardingRuleConfig.getBindingTableGroups().add("t_order,
t_order_item");
+ shardingRuleConfig.getBroadcastTables().add("t_country");
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new
InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
shardingRuleConfig.setDefaultTableShardingStrategyConfig(new
StandardShardingStrategyConfiguration("order_id", new
PreciseModuloShardingTableAlgorithm()));
return
ShardingDataSourceFactory.createDataSource(createDataSourceMap(),
shardingRuleConfig, new Properties());
}
private static TableRuleConfiguration getOrderTableRuleConfiguration() {
TableRuleConfiguration result = new TableRuleConfiguration("t_order",
"demo_ds_${0..1}.t_order_${[0, 1]}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
+ result.setKeyGeneratorConfig(new
KeyGeneratorConfiguration("SNOWFLAKE", "order_id", new Properties()));
Review comment:
it is better to remove order and orderItem configuration here.
----------------------------------------------------------------
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]
With regards,
Apache Git Services