Loading example-common/repository-api/src/main/java/io/shardingsphere/example/common/DataSourceUtil.java +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ public class DataSourceUtil { private static final String USER_NAME = "root"; private static final String PASSWORD = "liya76133951"; private static final String PASSWORD = ""; public static DataSource createDataSource(final String dataSourceName) { HikariDataSource result = new HikariDataSource(); Loading sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/JavaRangeConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.RangeOrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -47,6 +48,6 @@ public class JavaRangeConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } } sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/YamlConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.OrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -48,6 +49,6 @@ public class YamlConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new OrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new OrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } } sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/YamlRangeConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.RangeOrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -48,6 +49,6 @@ public class YamlRangeConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } } sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/config/ShardingDatabasesAndTablesConfigurationPrecise.java +5 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa 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()); Loading @@ -48,12 +49,14 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa 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())); return result; } private static TableRuleConfiguration getOrderItemTableRuleConfiguration() { return new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}"); TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}"); result.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "order_item_id", new Properties())); return result; } private static Map<String, DataSource> createDataSourceMap() { Loading @@ -62,8 +65,4 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa result.put("demo_ds_1", DataSourceUtil.createDataSource("demo_ds_1")); return result; } private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() { return new KeyGeneratorConfiguration("SNOWFLAKE", "order_id", new Properties()); } } Loading
example-common/repository-api/src/main/java/io/shardingsphere/example/common/DataSourceUtil.java +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ public class DataSourceUtil { private static final String USER_NAME = "root"; private static final String PASSWORD = "liya76133951"; private static final String PASSWORD = ""; public static DataSource createDataSource(final String dataSourceName) { HikariDataSource result = new HikariDataSource(); Loading
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/JavaRangeConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.RangeOrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -47,6 +48,6 @@ public class JavaRangeConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } }
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/YamlConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.OrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -48,6 +49,6 @@ public class YamlConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new OrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new OrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } }
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/YamlRangeConfigurationExample.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.example.sharding.data.jdbc; import io.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl; import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl; import io.shardingsphere.example.common.jdbc.repository.RangeOrderRepositoryImpl; import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl; Loading Loading @@ -48,6 +49,6 @@ public class YamlRangeConfigurationExample { } private static CommonService getCommonService(final DataSource dataSource) { return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource)); return new CommonServiceImpl(new RangeOrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource),new CountryRepositroyImpl(dataSource)); } }
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/io/shardingsphere/example/sharding/data/jdbc/config/ShardingDatabasesAndTablesConfigurationPrecise.java +5 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa 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()); Loading @@ -48,12 +49,14 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa 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())); return result; } private static TableRuleConfiguration getOrderItemTableRuleConfiguration() { return new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}"); TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}"); result.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "order_item_id", new Properties())); return result; } private static Map<String, DataSource> createDataSourceMap() { Loading @@ -62,8 +65,4 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa result.put("demo_ds_1", DataSourceUtil.createDataSource("demo_ds_1")); return result; } private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() { return new KeyGeneratorConfiguration("SNOWFLAKE", "order_id", new Properties()); } }