You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/11/29 15:47:56 UTC
[shardingsphere] branch master updated: Update transaction-examples to use ShardingSphere-Driver (#22510)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 6993ff8368f Update transaction-examples to use ShardingSphere-Driver (#22510)
6993ff8368f is described below
commit 6993ff8368f137ff7dd6a3ad31f80cc96329e02c
Author: Raigor <ra...@gmail.com>
AuthorDate: Tue Nov 29 23:47:47 2022 +0800
Update transaction-examples to use ShardingSphere-Driver (#22510)
---
.../transaction-2pc-xa-spring-boot-example/pom.xml | 2 +-
.../transaction/xa/spring/boot/XAOrderService.java | 3 -
...pplication-sharding-databases-tables.properties | 31 +---------
.../application-sharding-databases.properties | 27 +--------
.../application-sharding-tables.properties | 20 +------
.../main/resources/sharding-databases-tables.yaml | 68 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 60 +++++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 54 +++++++++++++++++
.../pom.xml | 2 +-
.../xa/spring/namspace/XAOrderService.java | 3 -
.../application-sharding-databases-tables.xml | 67 ++-------------------
.../META-INF/application-sharding-databases.xml | 48 ++-------------
.../META-INF/application-sharding-tables.xml | 45 ++------------
.../META-INF/sharding-databases-tables.yaml | 68 ++++++++++++++++++++++
.../resources/META-INF/sharding-databases.yaml | 60 +++++++++++++++++++
.../main/resources/META-INF/sharding-tables.yaml | 54 +++++++++++++++++
.../pom.xml | 2 +-
.../seata/spring/boot/SeataATOrderService.java | 3 -
...pplication-sharding-databases-tables.properties | 31 +---------
.../application-sharding-databases.properties | 27 +--------
.../application-sharding-tables.properties | 20 +------
.../main/resources/sharding-databases-tables.yaml | 68 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 60 +++++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 54 +++++++++++++++++
24 files changed, 579 insertions(+), 298 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/pom.xml
index a956aff53a1..cd1a75eac62 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/pom.xml
@@ -35,7 +35,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/boot/XAOrderService.java b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/boot/XAOrderService.java
index c5fdbe7857c..ee4455be33b 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/boot/XAOrderService.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/boot/XAOrderService.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.example.transaction.xa.spring.boot;
-import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.springframework.beans.factory.annotation.Autowired;
@@ -65,7 +64,6 @@ public class XAOrderService {
* @return transaction type
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.XA)
public TransactionType insert(final int count) {
return jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
@@ -79,7 +77,6 @@ public class XAOrderService {
* @param count insert record count
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.XA)
public void insertFailed(final int count) {
jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
index 25fbe52ae88..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,32 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-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.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases.properties
index 0e55209c211..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-databases.properties
@@ -15,28 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-tables.properties
index e55d9b968f5..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/application-sharding-tables.properties
@@ -15,21 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..72888da107c
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..c35fe556aa7
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,60 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..8f970c6ac28
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-boot-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_0.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+
+ shardingAlgorithms:
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/pom.xml
index b012d55ca06..dadc939dbeb 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/pom.xml
@@ -35,7 +35,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/namspace/XAOrderService.java b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/namspace/XAOrderService.java
index ab47d6c0015..815289e5216 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/namspace/XAOrderService.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/transaction/xa/spring/namspace/XAOrderService.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.example.transaction.xa.spring.namspace;
-import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.springframework.beans.factory.annotation.Autowired;
@@ -65,7 +64,6 @@ public class XAOrderService {
* @return transaction type
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.XA)
public TransactionType insert(final int count) {
return jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
@@ -79,7 +77,6 @@ public class XAOrderService {
* @param count insert record count
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.XA)
public void insertFailed(final int count) {
jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
index 4ac35bd97c6..2a4043c3c0b 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -20,82 +20,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
- xmlns:bean="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example" />
-
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:META-INF/sharding-databases-tables.yaml" />
</bean>
- <bean:properties id="databaseInlineProps">
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </bean:properties>
-
- <sharding:sharding-algorithm id="databaseInlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseInlineStrategyShardingAlgorithm" />
-
- <sharding:sharding-algorithm id="orderInlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderInlineStrategyShardingAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- </sharding:table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
-
- <shardingsphere:tx-type-annotation-driven />
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<tx:annotation-driven />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml
index 598ce34b08a..f1b35ee9e94 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -20,63 +20,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example" />
-
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:META-INF/sharding-databases.yaml" />
</bean>
- <sharding:sharding-algorithm id="databaseInlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseInlineStrategyShardingAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- </sharding:table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
-
- <shardingsphere:tx-type-annotation-driven />
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<tx:annotation-driven />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-tables.xml
index 4c2e4ee131c..6b5720072df 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -20,60 +20,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example" />
-
- <bean id="demo_ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:META-INF/sharding-tables.yaml" />
</bean>
- <sharding:sharding-algorithm id="orderInlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderInlineStrategyShardingAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- </sharding:table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
-
- <shardingsphere:tx-type-annotation-driven />
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="shardingDataSource" />
</bean>
+
<tx:annotation-driven />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..72888da107c
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases-tables.yaml
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases.yaml
new file mode 100644
index 00000000000..c35fe556aa7
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-databases.yaml
@@ -0,0 +1,60 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-tables.yaml
new file mode 100644
index 00000000000..8f970c6ac28
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-2pc-xa-spring-namespace-example/src/main/resources/META-INF/sharding-tables.yaml
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_0.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+
+ shardingAlgorithms:
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/pom.xml
index ee983732a40..a39de85a1f1 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/pom.xml
@@ -35,7 +35,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/base/seata/spring/boot/SeataATOrderService.java b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/base/seata/spring/boot/SeataATOrderService.java
index 6f291c395dc..11642843ec5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/base/seata/spring/boot/SeataATOrderService.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/java/org/apache/shardingsphere/example/transaction/base/seata/spring/boot/SeataATOrderService.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.example.transaction.base.seata.spring.boot;
-import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,7 +63,6 @@ public class SeataATOrderService {
* @return transaction type
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.BASE)
public TransactionType insert(final int count) {
return jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
@@ -78,7 +76,6 @@ public class SeataATOrderService {
* @param count insert record count
*/
@Transactional
- @ShardingSphereTransactionType(TransactionType.BASE)
public void insertFailed(final int count) {
jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
doInsert(count, preparedStatement);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
index 3fbe1102af6..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,32 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=123456
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=123456
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-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.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases.properties
index a8c575fb175..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-databases.properties
@@ -15,28 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-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.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-tables.properties
index c191e53a1cd..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/application-sharding-tables.properties
@@ -15,21 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=123456
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..a2631694e1a
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: BASE
+ providerType: Seata
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..336a1e02060
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,60 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: BASE
+ providerType: Seata
+
+props:
+ sql-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..5f8b6f953fc
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/transaction-example/transaction-base-seata-spring-boot-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_0.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+
+ shardingAlgorithms:
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+- !TRANSACTION
+ defaultType: BASE
+ providerType: Seata
+
+props:
+ sql-show: true