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/09/30 15:32:23 UTC

[shardingsphere] branch master updated: Add example test for single rule (#21288)

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 63bc42dc2ca Add example test for single rule (#21288)
63bc42dc2ca is described below

commit 63bc42dc2ca6c5e08111db7455e112a580d07b63
Author: Guocheng Tang <to...@apache.org>
AuthorDate: Fri Sep 30 23:32:12 2022 +0800

    Add example test for single rule (#21288)
    
    * add more test
    
    * remove dot
    
    * remove dot
    
    * remove dot
    
    * remove dot
    
    * remove dot
    
    * update ftl
    
    * update jdbc driver
    
    * remove type
    
    * add import
    
    * add import
    
    * update mysql
    
    * update shadow.ftl
    
    * update encrypt.ftl
    
    * fail fast
    
    * remove audit
    
    * add exclude
    
    * add exclude
    
    * add exclude
    
    * update encrypt.ftl
    
    * use service
    
    * use service
    
    * use service
    
    * use service
    
    * use service
    
    * use service
    
    * use service
    
    * update xa
    
    * update shadow
    
    * update datasource
    
    * update datasource
    
    * update datasource
    
    * init table
    
    * init table
    
    * update shadow.ftl
    
    * update shadow
---
 .github/workflows/ci-example-generator.yml         | 58 --------------
 .github/workflows/it-example-generator.yml         | 89 ++++++++++++++++++++++
 .../workflows}/mysql/init/init.sql                 |  0
 .../type/XANarayanaExampleScenario.java            |  5 +-
 .../template/jdbc/java/config/Configuration.ftl    | 12 ++-
 .../template/jdbc/java/config/encrypt.ftl          |  2 +-
 .../resources/template/jdbc/java/config/shadow.ftl |  4 +-
 .../template/jdbc/java/main/JDBCExampleMain.ftl    |  2 +-
 .../jdbc/java/repository/jpa/OrderRepository.ftl   |  8 --
 .../java/repository/mybatis/OrderRepository.ftl    | 16 ++--
 .../template/jdbc/resources/jbossts-properties.ftl | 46 +++++++++++
 .../mode/spring-boot-starter/standalone.ftl        |  2 +-
 .../mode/spring-namespace/config/standalone.ftl    |  3 +-
 .../resources/mode/spring-namespace/standalone.ftl |  2 +-
 .../jdbc/resources/properties/application.ftl      | 13 +++-
 .../template/jdbc/resources/properties/shadow.ftl  |  4 +-
 .../jdbc/resources/properties/sharding.ftl         |  6 +-
 .../template/jdbc/resources/xml/application.ftl    | 30 +++++---
 .../template/jdbc/resources/xml/encrypt.ftl        |  2 +-
 .../jdbc/resources/xml/readwrite-splitting.ftl     |  2 +-
 .../template/jdbc/resources/xml/shadow.ftl         |  7 +-
 .../template/jdbc/resources/xml/sharding.ftl       |  5 +-
 22 files changed, 207 insertions(+), 111 deletions(-)

diff --git a/.github/workflows/ci-example-generator.yml b/.github/workflows/ci-example-generator.yml
deleted file mode 100644
index 680e46ad563..00000000000
--- a/.github/workflows/ci-example-generator.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# 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.
-#
-
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
-name: Example Generator Test
-
-on:
-  push:
-    branches: [ master, dev ]
-  pull_request:
-    branches: [ master ]
-
-env:
-  MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3  -Drat.skip=true -Dcheckstyle.skip=true
-
-jobs:
-  shardingsphere-example-generator:
-    if: github.repository == 'apache/shardingsphere'
-    name: ${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        product: [ jdbc ]
-        mode: [ standalone ]
-        transaction: [ local ]
-        feature: [ sharding ]
-        framework: [ jdbc ]
-    steps:
-      - uses: actions/checkout@v3
-      - name: Set up JDK 8
-        uses: actions/setup-java@v2
-        with:
-          distribution: 'temurin'
-          java-version: 8
-      - name: Build Project
-        run: ./mvnw -B -ntp clean install -Dmaven.javadoc.skip=true -DskipITs -DskipTests -Dspotless.apply.skip=true
-      - name: Example generator
-        run: ./mvnw -B test -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
-      - name: Prepare The Docker Environment
-        run : docker-compose -f examples/shardingsphere-example-generator/docker-compose.yml up -d
-      - name: Example Test
-        run : ./mvnw -B test -f examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}/pom.xml -Pexample-generator -Dexec.cleanupDaemonThreads=false 
diff --git a/.github/workflows/it-example-generator.yml b/.github/workflows/it-example-generator.yml
new file mode 100644
index 00000000000..30f599d23ad
--- /dev/null
+++ b/.github/workflows/it-example-generator.yml
@@ -0,0 +1,89 @@
+#
+# 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.
+#
+
+# This workflow will build a Java project with Maven
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Auto Generator Example Test
+
+on:
+  push:
+    branches: [ master, dev ]
+    paths:
+      - '.github/workflows/it-example-generator.yml'
+      - '**/pom.xml'
+      - '**/src/main/**'
+      - 'examples/shardingsphere-example-generator/**'
+      - '!shardingsphere-distribution/**'
+      - '!shardingsphere-test/**'
+      - '!*.md'
+  pull_request:
+    branches: [ master ]
+
+env:
+  MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3  -Drat.skip=true -Dcheckstyle.skip=true
+
+jobs:
+  shardingsphere-example-generator:
+    if: github.repository == 'apache/shardingsphere'
+    name: ${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        product: [ jdbc ]
+        mode: [ standalone ]
+        transaction: [ local, xa-atomikos, xa-bitronix, xa-narayana ]
+        feature: [ sharding, readwrite-splitting, encrypt, shadow ]
+        framework: [ jdbc, spring-boot-starter-jdbc, spring-boot-starter-jpa, spring-boot-starter-mybatis, spring-namespace-jdbc, spring-namespace-jpa, spring-namespace-mybatis ]
+        exclude: 
+          - feature: shadow
+            framework: spring-boot-starter-jpa
+          - feature: shadow
+            framework: spring-namespace-jpa
+    services:
+      mysql:
+        image: mysql:8.0.22
+        env:
+          MYSQL_ROOT_PASSWORD: 123456
+        ports:
+          - 3306:3306
+        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
+    steps:
+      - uses: actions/checkout@v3
+      - name: Maven resolve ranges
+        run: ./mvnw versions:resolve-ranges -ntp -Dincludes='org.springframework:*,org.springframework.boot:*'
+      - uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '8'
+          cache: 'maven'
+      - name: Build with Maven
+        run: ./mvnw -B -ntp clean install -Dmaven.javadoc.skip=true -DskipITs -DskipTests -Dspotless.apply.skip=true
+      - name: Prepare Env
+        run: |
+          mysql -uroot -h127.0.0.1 -p123456 -e 'CREATE DATABASE IF NOT EXISTS demo_ds_0;CREATE DATABASE IF NOT EXISTS demo_ds_1;CREATE DATABASE IF NOT EXISTS demo_ds_2;'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_1;CREATE TABLE IF NOT EXISTS t_order(order_id BIGINT NOT NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id));'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_2;CREATE TABLE IF NOT EXISTS t_order(order_id BIGINT NOT NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id));'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_1;CREATE TABLE IF NOT EXISTS t_order_item(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY KEY (order_item_id));'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_2;CREATE TABLE IF NOT EXISTS t_order_item(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY KEY (order_item_id));'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_1;CREATE TABLE IF NOT EXISTS t_address (address_id BIGINT NOT NULL, address_name VARCHAR(100) NOT NULL, PRIMARY KEY (address_id));'
+          mysql -uroot -h127.0.0.1 -p123456 -e 'use demo_ds_2;CREATE TABLE IF NOT EXISTS t_address (address_id BIGINT NOT NULL, address_name VARCHAR(100) NOT NULL, PRIMARY KEY (address_id));'
+      - name: Example generator
+        run: ./mvnw -B test -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
+      - name: Example Test
+        run : ./mvnw -B test -f examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}/pom.xml -Pexample-generator -Dexec.cleanupDaemonThreads=false 
diff --git a/examples/shardingsphere-example-generator/mysql/init/init.sql b/.github/workflows/mysql/init/init.sql
similarity index 100%
rename from examples/shardingsphere-example-generator/mysql/init/init.sql
rename to .github/workflows/mysql/init/init.sql
diff --git a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/transaction/type/XANarayanaExampleScenario.java b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/transaction/type/XANarayanaExampleScenario.java
index 157dc027e9f..5726a13f1cb 100644
--- a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/transaction/type/XANarayanaExampleScenario.java
+++ b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/transaction/type/XANarayanaExampleScenario.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.example.generator.scenario.transaction.Transact
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 public class XANarayanaExampleScenario implements TransactionExampleScenario {
@@ -32,7 +33,9 @@ public class XANarayanaExampleScenario implements TransactionExampleScenario {
     
     @Override
     public Map<String, String> getResourceTemplateMap() {
-        return Collections.emptyMap();
+        Map<String, String> result = new HashMap<>(4, 1);
+        result.put("resources/jbossts-properties.ftl", "jbossts-properties.xml");
+        return result;
     }
     
     @Override
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
index 5b38cd9c592..f7aaf21e1f0 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
@@ -22,9 +22,12 @@ import com.zaxxer.hikari.HikariDataSource;
 import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+<#if mode=="standalone">
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryConfiguration;
+</#if>
 <#if feature?contains("sharding")>
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
 import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryConfiguration;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -35,6 +38,7 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardS
 <#if feature?contains("readwrite-splitting")>
 import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.strategy.StaticReadwriteSplittingStrategyConfiguration;
 </#if>
 <#if feature?contains("encrypt")>
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -49,7 +53,7 @@ import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
 import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
-import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
+import org.apache.shardingsphere.sql.parser.api.CacheOption;
 </#if>
 <#if feature?contains("db-discovery")>
 import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
@@ -100,8 +104,12 @@ public final class Configuration {
     private Map<String, DataSource> createDataSourceMap() {
         Map<String, DataSource> result = new LinkedHashMap<>();
         result.put("ds_0", createDataSource("demo_ds_0"));
+    <#if feature!="encrypt">
         result.put("ds_1", createDataSource("demo_ds_1"));
+        <#if feature!="shadow">
         result.put("ds_2", createDataSource("demo_ds_2"));
+        </#if>
+    </#if>
         return result;
     }
     
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
index 99b41092f41..118a981bbff 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
@@ -19,7 +19,7 @@
         Properties props = new Properties();
         props.setProperty("aes-key-value", "123456");
         EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("phone", "phone", "", "phone_plain", "phone_encryptor", null);
-        EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("status", "status", "assisted_query_status", "", "string_encryptor", null);
+        EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("status", "status", "assisted_query_status", "", "string_encryptor", "string_encryptor", null);
         EncryptTableRuleConfiguration orderItemRule = new EncryptTableRuleConfiguration("t_order_item", Collections.singleton(columnConfigAes), true);
         EncryptTableRuleConfiguration orderRule = new EncryptTableRuleConfiguration("t_order", Collections.singleton(columnConfigTest), true);
         Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new LinkedHashMap<>();
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
index 074c92970b5..79a50bcebd9 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
@@ -24,9 +24,7 @@
     } 
             
     private RuleConfiguration createSQLParserRuleConfiguration() {
-        SQLParserRuleConfiguration result = new DefaultSQLParserRuleConfigurationBuilder().build(); 
-        result.setSqlCommentParseEnabled(true);
-        return result;
+        return new SQLParserRuleConfiguration(true, new CacheOption(128, 1024L), new CacheOption(2000, 65535L));
     }
     
     private Map<String, ShadowTableConfiguration> createShadowTables() {
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/main/JDBCExampleMain.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/main/JDBCExampleMain.ftl
index 5fe2cc02237..33f3347c629 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/main/JDBCExampleMain.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/main/JDBCExampleMain.ftl
@@ -32,7 +32,7 @@ public final class ExampleMain {
         ExampleService exampleService = new ExampleService(dataSource);
         exampleService.run();
     <#if transaction=="xa-narayana">
-        System.exit(1);
+        System.exit(0);
     </#if>
     }
 }
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jpa/OrderRepository.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jpa/OrderRepository.ftl
index 337732617eb..006872426cd 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jpa/OrderRepository.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jpa/OrderRepository.ftl
@@ -54,14 +54,6 @@ public class OrderRepository {
         query.executeUpdate();
     }
     
-    <#if feature?contains("shadow")>
-    public void deleteShadow(final Long orderId) {
-        Query query = entityManager.createQuery("DELETE FROM Order o WHERE o.orderId = ?1 AND order_type=1");
-        query.setParameter(1, orderId);
-        query.executeUpdate();
-    }
-    </#if>
-    
     public List<Order> selectAll() {
         return (List<Order>) entityManager.createQuery("SELECT o FROM Order o").getResultList();
     }
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/mybatis/OrderRepository.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/mybatis/OrderRepository.ftl
index 2cdf48a5907..72615b4659e 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/mybatis/OrderRepository.ftl
@@ -25,13 +25,7 @@ import java.util.List;
 
 @Mapper
 public interface OrderRepository {
-    
-    void createTableIfNotExists();
-    
-    void truncateTable();
-    
-    void dropTable();
-    
+
 <#if feature?contains("shadow")>
     void createTableIfNotExistsShadow();
     
@@ -40,9 +34,15 @@ public interface OrderRepository {
     void dropTableShadow();
     
     List<Order> selectShadowOrder();
-
+    
     void deleteShadow(long orderId);
+    
 </#if>
+    void createTableIfNotExists();
+    
+    void truncateTable();
+    
+    void dropTable();
     
     void insert(Order order);
     
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/jbossts-properties.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/jbossts-properties.ftl
new file mode 100644
index 00000000000..3dfecae95be
--- /dev/null
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/jbossts-properties.ftl
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="CoordinatorEnvironmentBean.commitOnePhase">YES</entry>
+    <entry key="ObjectStoreEnvironmentBean.objectStoreDir">target</entry>
+    <entry key="com.arjuna.ats.arjuna.objectstore.objectStoreDir">target</entry>
+    <entry key="ObjectStoreEnvironmentBean.transactionSync">ON</entry>
+    <entry key="CoreEnvironmentBean.nodeIdentifier">1</entry>
+    <entry key="JTAEnvironmentBean.xaRecoveryNodes">1</entry>
+    <entry key="JTAEnvironmentBean.xaResourceOrphanFilterClassNames">
+        com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter
+        com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter
+        com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter
+    </entry>
+    <entry key="CoreEnvironmentBean.socketProcessIdPort">0</entry>
+    <entry key="RecoveryEnvironmentBean.recoveryModuleClassNames">
+        com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule
+        com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule
+    </entry>
+    <entry key="RecoveryEnvironmentBean.expiryScannerClassNames">
+        com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner
+    </entry>
+    <entry key="RecoveryEnvironmentBean.recoveryPort">4712</entry>
+    <entry key="RecoveryEnvironmentBean.recoveryAddress"></entry>
+    <entry key="RecoveryEnvironmentBean.transactionStatusManagerPort">0</entry>
+    <entry key="RecoveryEnvironmentBean.transactionStatusManagerAddress"></entry>
+    <entry key="RecoveryEnvironmentBean.recoveryListener">NO</entry>
+    <entry key="RecoveryEnvironmentBean.recoveryBackoffPeriod">1</entry>
+</properties>
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
index 68cefbc8786..30a7bd0d649 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
@@ -16,6 +16,6 @@
   -->
 
 spring.shardingsphere.mode.type=Standalone
-spring.shardingsphere.mode.repository.type=H2
+spring.shardingsphere.mode.repository.type=JDBC
 spring.shardingsphere.mode.repository.props.path=demo
 spring.shardingsphere.mode.overwrite=false
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl
index 0c34f2efe55..9e5f8bf3a5b 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl
@@ -14,5 +14,4 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-
-<standalone:repository id="standaloneRepository" type="H2" />
+    <standalone:repository id="standaloneRepository" type="JDBC" />
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/standalone.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/standalone.ftl
index 32c468f7bb5..47a5e646e50 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/standalone.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/standalone.ftl
@@ -14,4 +14,4 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="true" />
+        <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="true" />
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/application.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/application.ftl
index 2ffbba9e9b2..8383c9cb791 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/application.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/application.ftl
@@ -30,7 +30,14 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
 spring.jpa.properties.hibernate.show_sql=false
 </#if>
 
-spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
+<#assign datasourceStr="ds-0">
+<#if feature!="encrypt">
+    <#assign datasourceStr += ",ds-1" />
+    <#if feature!="shadow">
+        <#assign datasourceStr += ",ds-2" />
+    </#if>
+</#if>
+spring.shardingsphere.datasource.names=${datasourceStr}
 
 spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
 spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.cj.jdbc.Driver
@@ -39,6 +46,7 @@ spring.shardingsphere.datasource.ds-0.username=${username}
 spring.shardingsphere.datasource.ds-0.password=${(password)?string}
 spring.shardingsphere.datasource.ds-0.max-active=16
 
+<#if feature!="encrypt">
 spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
 spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://${host}:${port}/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
@@ -46,12 +54,15 @@ spring.shardingsphere.datasource.ds-1.username=${username}
 spring.shardingsphere.datasource.ds-1.password=${(password)?string}
 spring.shardingsphere.datasource.ds-1.max-active=16
 
+<#if feature!="shadow">
 spring.shardingsphere.datasource.ds-2.type=com.zaxxer.hikari.HikariDataSource
 spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.shardingsphere.datasource.ds-2.jdbc-url=jdbc:mysql://${host}:${port}/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
 spring.shardingsphere.datasource.ds-2.username=${username}
 spring.shardingsphere.datasource.ds-2.password=${(password)?string}
 spring.shardingsphere.datasource.ds-2.max-active=16
+</#if>
+</#if>
 <#list feature?split(",") as item>
     <#include "${item}.ftl">
 </#list>
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/shadow.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/shadow.ftl
index 9eacfd73a0d..ac3d28339e1 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/shadow.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/shadow.ftl
@@ -18,6 +18,8 @@
 spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=ds-0
 spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds-1
 
+spring.shardingsphere.rules.shadow.default-shadow-algorithm-name=simple-hint-algorithm
+
 spring.shardingsphere.rules.shadow.tables.t_order.data-source-names=shadow-data-source
 spring.shardingsphere.rules.shadow.tables.t_order.shadow-algorithm-names=user-id-insert-match-algorithm,user-id-delete-match-algorithm,user-id-select-match-algorithm,simple-hint-algorithm
 
@@ -41,5 +43,3 @@ spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props
 spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
 
 spring.shardingsphere.rules.sql-parser.sql-comment-parse-enabled=true
-
-spring.shardingsphere.props.sql-show=true
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/sharding.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/sharding.ftl
index e2085a1dedb..6d569798d80 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/sharding.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/properties/sharding.ftl
@@ -27,8 +27,8 @@ spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.shar
 
 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.tables.t_order.audit-strategy.auditor-names=shardingKeyAudit
-spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.allow-hint-disable=true
+#spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.auditor-names=shardingKeyAudit
+#spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.allow-hint-disable=true
 
 spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
 spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
@@ -46,4 +46,4 @@ spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.pro
 
 spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
 
-spring.shardingsphere.rules.sharding.auditors.shardingKeyAudit.type=DML_SHARDING_CONDITIONS
+#spring.shardingsphere.rules.sharding.auditors.shardingKeyAudit.type=DML_SHARDING_CONDITIONS
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/application.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/application.ftl
index c80859fb0c1..d63bce142e2 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/application.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/application.ftl
@@ -84,25 +84,27 @@
     -->
     
     <bean id="ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
+        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_0?serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="${username}"/>
         <property name="password" value="${(password)?string}"/>
     </bean>
-    
+<#if feature!="encrypt">
     <bean id="ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
+        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_1?serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="${username}"/>
         <property name="password" value="${(password)?string}"/>
     </bean>
-    
+    <#if feature!="shadow">
     <bean id="ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_2?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
+        <property name="jdbcUrl" value="jdbc:mysql://${host}:${port}/demo_ds_2?serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="${username}"/>
         <property name="password" value="${(password)?string}"/>
     </bean>
+    </#if>
+</#if>
 <#list feature?split(",") as item>
     <#include "${item}.ftl">
 </#list>
@@ -134,7 +136,17 @@
         <#assign ruleRefs += ", " />
     </#if>
 </#list>
-    <shardingsphere:data-source id="dataSource" data-source-names="ds_0, ds_1, ds_2" rule-refs="${ruleRefs}">
+<#if feature?contains("shadow")>
+    <#assign ruleRefs += ", sqlParseRule" />
+</#if>
+<#assign datasourceStr="ds_0">
+<#if feature!="encrypt">
+    <#assign datasourceStr += ",ds_1" />
+    <#if feature!="shadow">
+        <#assign datasourceStr += ",ds_2" />
+    </#if>
+</#if>
+    <shardingsphere:data-source id="dataSource" data-source-names="${datasourceStr}" rule-refs="${ruleRefs}">
         <#if mode?contains("cluster")>
             <#include "../mode/spring-namespace/cluster.ftl" />
         <#elseif mode?contains("standalone")>
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/encrypt.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/encrypt.ftl
index 7b47a89799e..64702f74035 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/encrypt.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/encrypt.ftl
@@ -24,7 +24,7 @@
     
     <encrypt:rule id="encryptRule">
         <encrypt:table name="t_order">
-            <encrypt:column logic-column="status" cipher-column="status" assisted-query-column="assisted_query_status" encrypt-algorithm-ref="string_encryptor" />
+            <encrypt:column logic-column="status" cipher-column="status" assisted-query-column="assisted_query_status" encrypt-algorithm-ref="string_encryptor" assisted-query-encrypt-algorithm-ref="string_encryptor" />
         </encrypt:table>
         <encrypt:table name="t_order_item">
             <encrypt:column logic-column="phone" cipher-column="phone" plain-column="phone_plain" encrypt-algorithm-ref="phone_encryptor" />
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/readwrite-splitting.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/readwrite-splitting.ftl
index 3265b566f13..a56cfb002be 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/readwrite-splitting.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/readwrite-splitting.ftl
@@ -18,7 +18,7 @@
     <readwrite-splitting:load-balance-algorithm id="randomStrategy" type="RANDOM" />
     
     <readwrite-splitting:rule id="readwriteSplittingRule">
-        <readwrite-splitting:data-source-rule id="demo_ds" type="Static" load-balance-algorithm-ref="randomStrategy">
+        <readwrite-splitting:data-source-rule id="demo_ds" load-balance-algorithm-ref="randomStrategy">
             <readwrite-splitting:static-strategy id="staticStrategy" write-data-source-name="ds_0" read-data-source-names="ds_1, ds_2"/>
         </readwrite-splitting:data-source-rule>
     </readwrite-splitting:rule>
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
index 929a4d85c75..6c33d2e359e 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
@@ -54,15 +54,10 @@
             <shadow:algorithm shadow-algorithm-ref="user-id-select-match-algorithm" />
             <shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
         </shadow:shadow-table>
+        <shadow:default-shadow-algorithm-name name="simple-hint-algorithm"/>
     </shadow:rule>
     
     <sql-parser:rule id="sqlParseRule" sql-comment-parse-enable="true" parse-tree-cache-ref="parserTreeCache" sql-statement-cache-ref="sqlStatementCache" />
     
     <sql-parser:cache-option id="sqlStatementCache" initial-capacity="1024" maximum-size="1024"/>
     <sql-parser:cache-option id="parserTreeCache" initial-capacity="1024" maximum-size="1024"/>
-    
-    <shardingsphere:data-source id="dataSource" data-source-names="ds_0, ds_1" rule-refs="shadowRule, sqlParseRule">
-        <props>
-            <prop key="sql-show">true</prop>
-        </props>
-    </shardingsphere:data-source>
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/sharding.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/sharding.ftl
index 8adbe9cbcd6..0365a8f5a82 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/sharding.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/sharding.ftl
@@ -40,8 +40,9 @@
     
     <sharding:rule id="shardingRule">
         <sharding:table-rules>
-            <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" audit-strategy-ref="shardingKeyAudit" />
-            <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" audit-strategy-ref="shardingKeyAudit" />
+            <!--todo add audit-->
+            <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
+            <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" />
             <sharding:table-rule logic-table="t_account" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="accountKeyGenerator" />
         </sharding:table-rules>
         <sharding:binding-table-rules>