You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/11/08 02:50:46 UTC
[shardingsphere] branch master updated: fix hint example (#21931)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 5b235c05134 fix hint example (#21931)
5b235c05134 is described below
commit 5b235c0513465528c8e17dfc6a8dd59c6f4249bc
Author: 本宫在,尔等都是妃 <11...@qq.com>
AuthorDate: Tue Nov 8 10:50:39 2022 +0800
fix hint example (#21931)
* #18932: fix bug in spi-based-sharding-spring-boot-jpa-example
* fix hint example
* fix: Can not find shardingAlgorithm `database-inline` in database `logic_db`.
* bugfix #21955: No implementation class load from SPI org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository with type H2.
* bugfix: Some test cases have incorrect configuration information
Co-authored-by: qubo <“doveylovey@126.com”>
---
.../example/sharding/raw/jdbc/ShardingHintRawExample.java | 6 +++---
.../raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java | 2 +-
.../src/main/resources/application-sharding-auto-tables.properties | 3 +++
.../src/main/resources/application.properties | 4 ++--
.../src/main/resources/application-sharding-auto-tables.properties | 3 +++
.../src/main/resources/application-sharding-tables.properties | 2 +-
6 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingHintRawExample.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingHintRawExample.java
index a9319c2f0a3..3fc9cc5b371 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingHintRawExample.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingHintRawExample.java
@@ -77,11 +77,11 @@ public final class ShardingHintRawExample {
private static void setHintValue(final HintManager hintManager) {
switch (TYPE) {
case SHARDING_HINT_DATABASES_ONLY:
- hintManager.addDatabaseShardingValue("t_order", 2L);
- hintManager.addTableShardingValue("t_order", 1L);
+ hintManager.setDatabaseShardingValue(1L);
return;
case SHARDING_HINT_DATABASES_TABLES:
- hintManager.setDatabaseShardingValue(1L);
+ hintManager.addDatabaseShardingValue("t_order", 2L);
+ hintManager.addTableShardingValue("t_order", 1L);
return;
default:
throw new UnsupportedOperationException("unsupported type");
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
index 80a4f4a94a4..bf5351f34b3 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
@@ -56,7 +56,7 @@ public final class ShardingDatabasesConfigurationPrecise implements ExampleConfi
}
private ModeConfiguration createModeConfiguration() {
- return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("H2", new Properties()));
+ return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("JDBC", new Properties()));
}
private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
index 5a420632c1b..0a72127672a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
@@ -49,6 +49,9 @@ spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.
spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
+
spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
index 7378abebf8b..089beafcac9 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
@@ -19,7 +19,7 @@ spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.show_sql=false
-spring.profiles.active=sharding-databases
+#spring.profiles.active=sharding-databases
#spring.profiles.active=sharding-tables
#spring.profiles.active=sharding-databases-tables
-#spring.profiles.active=sharding-auto-tables
+spring.profiles.active=sharding-auto-tables
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
index 5a420632c1b..0a72127672a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
@@ -49,6 +49,9 @@ spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.
spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
+
spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
index 7d689df23d5..83eb6e33488 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
@@ -15,7 +15,7 @@
# limitations under the License.
#
-spring.shardingsphere.mode.type=Memory
+spring.shardingsphere.mode.type=Standalone
spring.shardingsphere.datasource.names=ds