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 96b7609  Add shadow spring namespace example and adjust template 
(#13954)
96b7609 is described below

commit 96b760938d51552a250f6546ce41ee8e4bc1140d
Author: Guocheng Tang <[email protected]>
AuthorDate: Wed Dec 8 12:27:00 2021 +0800

    Add shadow spring namespace example and adjust template (#13954)
    
    * Add shadow spring namespace example and adjust template
    
    * Add shadow spring namespace example and adjust template
---
 .../spring-namespace-jdbc/data-model.yaml          |   2 +-
 .../dataModel/spring-namespace-jpa/data-model.yaml |   2 +-
 .../spring-namespace-mybatis/data-model.yaml       |   2 +-
 .../src/main/resources/template/ExampleService.ftl |  10 +-
 .../main/resources/template/jpa/ExampleService.ftl |   6 +-
 .../src/main/resources/template/jpa/Repository.ftl |   6 +-
 ...rExampleService.ftl => orderExampleService.ftl} |   0
 .../{otherRepository.ftl => orderRepository.ftl}   |   0
 ...ptExampleService.ftl => userExampleService.ftl} |   0
 .../{encryptRepository.ftl => userRepository.ftl}  |   0
 ...rExampleService.ftl => orderExampleService.ftl} |   0
 ...ptExampleService.ftl => userExampleService.ftl} |   0
 .../main/resources/template/xml/application.ftl    |   5 +
 .../resources/template/xml/shadowApplication.ftl   |  64 +++++++++
 .../pom.xml                                        |   3 +
 .../pom.xml                                        |   1 -
 .../jdbc/MemoryLocalShadowJdbcConfiguration.java   |   1 -
 .../pom.xml                                        |  10 +-
 ...moryLocalShadowSpringNamespaceJdbcExample.java} |  29 ++--
 ...calShadowSpringNamespaceJdbcExampleService.java | 153 +++++++++++++++++++++
 .../shadow/spring/namespace/jdbc/entity/User.java  |  60 ++++++++
 .../src/main/resources/application.xml}            | 100 ++++++++------
 .../src/main/resources/logback.xml}                |  25 +++-
 .../pom.xml                                        |  25 +++-
 ...emoryLocalShadowSpringNamespaceJpaExample.java} |  35 ++---
 ...calShadowSpringNamespaceJpaExampleService.java} |  16 +--
 ...ryLocalShadowSpringNamespaceJpaRepository.java} |  14 +-
 .../shadow/spring/namespace/jpa/entity/User.java   |  73 ++++++++++
 .../src/main/resources/application.xml}            |  86 ++++++++----
 .../src/main/resources/logback.xml}                |  25 +++-
 .../pom.xml                                        |  21 ++-
 ...yLocalShadowSpringNamespaceMybatisExample.java} |  29 ++--
 ...hadowSpringNamespaceMybatisExampleService.java} |  76 +++++-----
 .../spring/namespace/mybatis/entity/User.java      |  60 ++++++++
 .../mybatis/repository/UserRepository.java}        |  12 +-
 .../src/main/resources/application.xml}            |  90 +++++++-----
 .../src/main/resources/logback.xml}                |  25 +++-
 .../src/main/resources/mappers/UserMapper.xml      |  51 +++++++
 38 files changed, 848 insertions(+), 269 deletions(-)

diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
index afbc2b9..b5eee94 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
@@ -17,6 +17,6 @@
 
 mode: memory
 transaction: local
-feature: encrypt
+feature: shadow
 framework: spring-namespace-jdbc
 
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
index ba93ef4..6f61fbf 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
@@ -17,6 +17,6 @@
 
 mode: memory
 transaction: local
-feature: encrypt
+feature: shadow
 framework: spring-namespace-jpa
 
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
index b0a2719..c40aaad 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
@@ -17,6 +17,6 @@
 
 mode: memory
 transaction: local
-feature: encrypt
+feature: shadow
 framework: spring-namespace-mybatis
 
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
index 04373ed..cccebbf 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
 
-<#if feature=="encrypt">
+<#if feature=="encrypt" || feature=="shadow">
 import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
 import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.UserRepository;
 <#else>
@@ -44,7 +44,7 @@ import java.util.List;
 @Service
 public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
 
-<#if feature=="encrypt">
+<#if feature=="encrypt" || feature=="shadow">
     @Resource
     private UserRepository userRepository;
 <#else>
@@ -68,9 +68,9 @@ public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${fram
             this.cleanEnvironment();
         }
     }
-<#if feature=="encrypt">
-    <#include "encryptExampleService.ftl">
+<#if feature=="encrypt" || feature=="shadow">
+    <#include "userExampleService.ftl">
 <#else>
-    <#include "otherExampleService.ftl">
+    <#include "orderExampleService.ftl">
 </#if>
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
index 3263f28..9c13a03 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
@@ -14,8 +14,8 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<#if feature=="encrypt">
-    <#include "encryptExampleService.ftl">
+<#if feature=="encrypt" || feature=="shadow">
+    <#include "userExampleService.ftl">
 <#else>
-    <#include "otherExampleService.ftl">
+    <#include "orderExampleService.ftl">
 </#if>
\ No newline at end of file
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
index 07a6219..89be4ab 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
@@ -14,8 +14,8 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<#if feature=="encrypt">
-    <#include "encryptRepository.ftl">
+<#if feature=="encrypt" || feature=="shadow">
+    <#include "userRepository.ftl">
 <#else>
-    <#include "otherRepository.ftl">
+    <#include "orderRepository.ftl">
 </#if>
\ No newline at end of file
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderExampleService.ftl
similarity index 100%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherExampleService.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderExampleService.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderRepository.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderRepository.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userExampleService.ftl
similarity index 100%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptExampleService.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userExampleService.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userRepository.ftl
similarity index 100%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptRepository.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userRepository.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/otherExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/orderExampleService.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/otherExampleService.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/orderExampleService.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/encryptExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/userExampleService.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/encryptExampleService.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/userExampleService.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
index 72e55aa..3da5275 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
@@ -25,6 +25,7 @@
        
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
        
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
        
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt";
+       
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
@@ -39,6 +40,8 @@
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
                            ">
     <context:annotation-config />
     <context:component-scan 
base-package="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}"/>
@@ -80,6 +83,8 @@
     <#include "readwriteSplittingApplication.ftl">
 <#elseif feature=="encrypt">
     <#include "encryptApplication.ftl">
+<#elseif feature=="shadow">
+    <#include "shadowApplication.ftl">
 </#if>
     
 <#if framework=="spring-namespace-mybatis">
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/shadowApplication.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/shadowApplication.ftl
new file mode 100644
index 0000000..2bf41e4
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/shadowApplication.ftl
@@ -0,0 +1,64 @@
+<#--
+  ~ 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.
+  -->
+
+    <shadow:shadow-algorithm id="user-id-insert-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">insert</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-delete-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">delete</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-select-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">select</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="simple-hint-algorithm" type="SIMPLE_HINT">
+        <props>
+            <prop key="shadow">true</prop>
+            <prop key="foo">bar</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:rule id="shadowRule" enable="true">
+        <shadow:data-source id="shadow-data-source" 
source-data-source-name="demo_ds_0" shadow-data-source-name="demo_ds_1"/>
+        <shadow:shadow-table name="t_user" data-sources="shadow-data-source">
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-insert-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-delete-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-select-match-algorithm" />
+            <shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
+        </shadow:shadow-table>
+    </shadow:rule>
+
+    <shardingsphere:data-source id="dataSource" 
data-source-names="demo_ds_0,demo_ds_1" rule-refs="shadowRule">
+        <props>
+            <prop key="sql-show">true</prop>
+            <prop key="sql-comment-parse-enabled">true</prop>
+        </props>
+    </shardingsphere:data-source>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
index b76cce8..c87e35c 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
@@ -31,6 +31,9 @@
     
     <modules>
         <module>shardingsphere-jdbc-memory-local-shadow-jdbc-example</module>
+        
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example</module>
+        
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example</module>
+        
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example</module>
     </modules>
     
 </project>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
index 8b6e657..12e4868 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
@@ -25,7 +25,6 @@
         <version>${revision}</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
     
<artifactId>shardingsphere-jdbc-memory-local-shadow-jdbc-example</artifactId>
     <name>${project.artifactId}</name>
     
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/jdbc/MemoryLocalShadowJdbcConfiguration.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardings
 [...]
index 3408ea0..90823c0 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/jdbc/MemoryLocalShadowJdbcConfiguration.java
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/jdbc/MemoryLocalShadowJdbcConfiguration.java
@@ -60,7 +60,6 @@ public final class MemoryLocalShadowJdbcConfiguration {
     private Properties createShardingSphereProps() {
         Properties result = new Properties();
         result.setProperty(ConfigurationPropertyKey.SQL_SHOW.getKey(), "true");
-        
result.setProperty(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey(), 
"true");
         return result;
     }
 
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namesp
 [...]
similarity index 80%
copy from 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/pom.xml
index 8b6e657..aa303ac 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/pom.xml
@@ -25,14 +25,18 @@
         <version>${revision}</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    
<artifactId>shardingsphere-jdbc-memory-local-shadow-jdbc-example</artifactId>
+    
<artifactId>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example</artifactId>
     <name>${project.artifactId}</name>
     
     <dependencies>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-jdbc-core</artifactId>
+            <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>5.1.5.RELEASE</version>
         </dependency>
     </dependencies>
     
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/MemoryLocalShadowSpringNa
 [...]
similarity index 53%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/MemoryLocalShadowSpringNamespaceJdbcExample.java
index afbde72..540c8e5 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/MemoryLocalShadowSpringNamespaceJdbcExample.java
@@ -15,25 +15,18 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.shadow.spring.namespace.jdbc;
 
-import org.apache.ibatis.annotations.Mapper;
-import 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.sql.SQLException;
 
-import java.util.List;
-
-@Mapper
-public interface OrderItemRepository {
-    
-    void createTableIfNotExists();
-    
-    void truncateTable();
-    
-    void dropTable();
-    
-    void insert(OrderItem orderItem);
-    
-    void delete(long orderId);
+public class MemoryLocalShadowSpringNamespaceJdbcExample {
     
-    List<OrderItem> selectAll();
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = new 
ClassPathXmlApplicationContext("application.xml")) {
+            MemoryLocalShadowSpringNamespaceJdbcExampleService exampleService 
= 
applicationContext.getBean(MemoryLocalShadowSpringNamespaceJdbcExampleService.class);
+            exampleService.run();
+        }
+    }
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/MemoryLocalShadowSpringNamespaceJdbcExampleService.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/
 [...]
new file mode 100644
index 0000000..c2a6dd5
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/MemoryLocalShadowSpringNamespaceJdbcExampleService.java
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.example.shadow.spring.namespace.jdbc;
+
+import lombok.AllArgsConstructor;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.jdbc.entity.User;
+import org.springframework.stereotype.Service;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public final class MemoryLocalShadowSpringNamespaceJdbcExampleService {
+    
+    private final DataSource dataSource;
+
+    /**
+     * Execute test.
+     *
+     * @throws SQLException
+     */
+    public void run() throws SQLException {
+        try {
+            this.initEnvironment();
+            this.processSuccess();
+        } finally {
+            this.cleanEnvironment();
+        }
+    }
+    
+
+    /**
+     * Initialize the database test environment.
+     * @throws SQLException
+     */
+    private void initEnvironment() throws SQLException {
+        String createUserTableSql = "CREATE TABLE IF NOT EXISTS t_user" 
+                + "(user_id INT NOT NULL AUTO_INCREMENT, user_name 
VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY (user_id))";
+        String truncateUserTable = "TRUNCATE TABLE t_user";
+        
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(createUserTableSql);
+            statement.executeUpdate(truncateUserTable);
+        }
+    }
+    
+    private void processSuccess() throws SQLException {
+        System.out.println("-------------- Process Success Begin 
---------------");
+        List<Long> ids = insertData();
+        printData(); 
+        deleteData(ids);
+        printData();
+        System.out.println("-------------- Process Success Finish 
--------------");
+    }
+
+    private List<Long> insertData() throws SQLException {
+        System.out.println("---------------------------- Insert Data 
----------------------------");
+        List<Long> result = new ArrayList<>(10);
+        for (int i = 1; i <= 10; i++) {
+            User user = new User();
+            user.setUserId(i);
+            user.setUserName("test_" + i);
+            user.setPwd("pwd" + i);
+            insert(user);
+            result.add((long) user.getUserId());
+        }
+        return result;
+    }
+    
+    private long insert(final User user) throws SQLException {
+        String sql = "INSERT INTO t_user (user_id, user_name, pwd) VALUES (?, 
?, ?)";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql)) {
+            preparedStatement.setInt(1, user.getUserId());
+            preparedStatement.setString(2, user.getUserName());
+            preparedStatement.setString(3, user.getPwd());
+            preparedStatement.executeUpdate();
+        }
+        return user.getUserId();
+    }
+
+    private void deleteData(final List<Long> orderIds) throws SQLException {
+        System.out.println("---------------------------- Delete Data 
----------------------------");
+        String sql = "DELETE FROM t_user WHERE user_id=?";
+        for (Long each : orderIds) {
+            try (Connection connection = dataSource.getConnection();
+                 PreparedStatement preparedStatement = 
connection.prepareStatement(sql)) {
+                preparedStatement.setLong(1, each);
+                preparedStatement.executeUpdate();
+            }
+        }
+    }
+    
+    private void printData() throws SQLException {
+        System.out.println("---------------------------- Print User Data 
-----------------------");
+        for (Object each : this.getUsers()) {
+            System.out.println(each);
+        }
+    }
+
+    protected List<User> getUsers() throws SQLException {
+        List<User> result = new LinkedList<>();
+        String sql = "SELECT * FROM t_user";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql);
+             ResultSet resultSet = preparedStatement.executeQuery()) {
+            while (resultSet.next()) {
+                User user = new User();
+                user.setUserId(resultSet.getInt("user_id"));
+                user.setUserName(resultSet.getString("user_name"));
+                user.setPwd(resultSet.getString("pwd"));
+                result.add(user);
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * Restore the environment.
+     * @throws SQLException
+     */
+    private void cleanEnvironment() throws SQLException {
+        String dropUserSql = "DROP TABLE t_user";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(dropUserSql);
+        }
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/entity/User.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-exampl
 [...]
new file mode 100644
index 0000000..e0c018a
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jdbc/entity/User.java
@@ -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.
+ */
+
+package org.apache.shardingsphere.example.shadow.spring.namespace.jdbc.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+    
+    private static final long serialVersionUID = 263434701950670170L;
+    
+    private int userId;
+
+    private String userName;
+
+    private String pwd;
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getUserName() {
+        return userName;
+    }
+    
+    public void setUserName(final String userName) {
+        this.userName = userName;
+    }
+    
+    public String getPwd() {
+        return pwd;
+    }
+    
+    public void setPwd(final String pwd) {
+        this.pwd = pwd;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("user_id: %d, user_name: %s, pwd: %s", userId, 
userName, pwd);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/application.xml
similarity index 58%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/application.xml
index 72e55aa..9d1ce9b 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/application.xml
@@ -25,6 +25,7 @@
        
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
        
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
        
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt";
+       
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
@@ -39,63 +40,72 @@
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan 
base-package="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}"/>
-<#if framework=="spring-namespace-jpa">
-    <bean id="entityManagerFactory" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="jpaVendorAdapter">
-            <bean 
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
p:database="MYSQL" />
-        </property>
-        <property name="packagesToScan" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity" />
-        <property name="jpaProperties">
-            <props>
-                <prop 
key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
-                <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
-                <prop key="hibernate.show_sql">false</prop>
-            </props>
-        </property>
-    </bean>
-    <bean id="transactionManager" 
class="org.springframework.orm.jpa.JpaTransactionManager" 
p:entityManagerFactory-ref="entityManagerFactory" />
-    <tx:annotation-driven />
-</#if>
+    <context:component-scan 
base-package="org.apache.shardingsphere.example.shadow.spring.namespace.jdbc"/>
     
     <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:3307/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
+        <property name="password" value="root"/>
     </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:3307/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
-    </bean>
-<#if feature=="sharding">
-    <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-    <#include "readwriteSplittingApplication.ftl">
-<#elseif feature=="encrypt">
-    <#include "encryptApplication.ftl">
-</#if>
-    
-<#if framework=="spring-namespace-mybatis">
-    <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource" ref="dataSource" />
+        <property name="password" value="root"/>
     </bean>
-    <tx:annotation-driven />
 
-    <bean id="sqlSessionFactory" 
class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource"/>
-        <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
-    </bean>
+    <shadow:shadow-algorithm id="user-id-insert-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">insert</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
 
-    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository"/>
-        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
-    </bean>
-</#if>
+    <shadow:shadow-algorithm id="user-id-delete-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">delete</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-select-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">select</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="simple-hint-algorithm" type="SIMPLE_HINT">
+        <props>
+            <prop key="shadow">true</prop>
+            <prop key="foo">bar</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:rule id="shadowRule" enable="true">
+        <shadow:data-source id="shadow-data-source" 
source-data-source-name="demo_ds_0" shadow-data-source-name="demo_ds_1"/>
+        <shadow:shadow-table name="t_user" data-sources="shadow-data-source">
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-insert-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-delete-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-select-match-algorithm" />
+            <shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
+        </shadow:shadow-table>
+    </shadow:rule>
+
+    <shardingsphere:data-source id="dataSource" 
data-source-names="demo_ds_0,demo_ds_1" rule-refs="shadowRule">
+        <props>
+            <prop key="sql-show">true</prop>
+            <prop key="sql-comment-parse-enabled">true</prop>
+        </props>
+    </shardingsphere:data-source>
+    
 </beans>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/logback.xml
similarity index 56%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/logback.xml
index 3263f28..154abba 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example/src/main/resources/logback.xml
@@ -1,4 +1,5 @@
-<#--
+<?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.
@@ -14,8 +15,20 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<#if feature=="encrypt">
-    <#include "encryptExampleService.ftl">
-<#else>
-    <#include "otherExampleService.ftl">
-</#if>
\ No newline at end of file
+
+<configuration>
+    <property name="log.context.name" value="shardingsphere-example" />
+    <property name="log.charset" value="UTF-8" />
+    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] 
%msg %n" />
+    <contextName>${log.context.name}</contextName>
+    
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namesp
 [...]
similarity index 62%
copy from 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/pom.xml
index 8b6e657..206d493 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/pom.xml
@@ -25,14 +25,33 @@
         <version>${revision}</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    
<artifactId>shardingsphere-jdbc-memory-local-shadow-jdbc-example</artifactId>
+    
<artifactId>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example</artifactId>
     <name>${project.artifactId}</name>
     
     <dependencies>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-jdbc-core</artifactId>
+            <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.1-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-entitymanager</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-orm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
         </dependency>
     </dependencies>
     
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespac
 [...]
similarity index 53%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaExample.java
index 28d0500..d9115a8 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaExample.java
@@ -15,25 +15,18 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
-
-import org.apache.ibatis.annotations.Mapper;
-import 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.Order;
-
-import java.util.List;
-
-@Mapper
-public interface OrderRepository {
-
-    void createTableIfNotExists();
-
-    void truncateTable();
-
-    void dropTable();
-
-    void insert(Order order);
-
-    void delete(long orderId);
-
-    List<Order> selectAll();
+package org.apache.shardingsphere.example.shadow.spring.namespace.jpa;
+
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.sql.SQLException;
+
+public class MemoryLocalShadowSpringNamespaceJpaExample {
+    
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = new 
ClassPathXmlApplicationContext("application.xml")) {
+            MemoryLocalShadowSpringNamespaceJpaExampleService exampleService = 
applicationContext.getBean(MemoryLocalShadowSpringNamespaceJpaExampleService.class);
+            exampleService.run();
+        }
+    }
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespace
 [...]
similarity index 76%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptExampleService.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaExampleService.java
index a62ec53..0f0c43c 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaExampleService.java
@@ -15,28 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.shadow.spring.namespace.jpa;
 
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.jpa.entity.User;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
 @Service
-public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
+public final class MemoryLocalShadowSpringNamespaceJpaExampleService {
 
     @Resource
-    private 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 repository;
+    private MemoryLocalShadowSpringNamespaceJpaRepository repository;
 
     /**
      * Execute test.
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaR
 [...]
similarity index 73%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaRepository.java
index c65dceb..53a5311 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/encryptRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/MemoryLocalShadowSpringNamespaceJpaRepository.java
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.shadow.spring.namespace.jpa;
 
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.jpa.entity.User;
 import org.springframework.stereotype.Repository;
 
 import javax.persistence.EntityManager;
@@ -26,17 +26,9 @@ import javax.persistence.Query;
 import javax.transaction.Transactional;
 import java.util.List;
 
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
 @Repository
 @Transactional
-public class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 {
+public class MemoryLocalShadowSpringNamespaceJpaRepository {
     
     @PersistenceContext
     private EntityManager entityManager;
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/entity/User.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/
 [...]
new file mode 100644
index 0000000..e6fce6f
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/jpa/entity/User.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.example.shadow.spring.namespace.jpa.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "t_user")
+public class User implements Serializable {
+    
+    private static final long serialVersionUID = 263434701950670170L;
+    
+    @Id
+    @Column(name = "user_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int userId;
+
+    @Column(name = "user_name")
+    private String userName;
+
+    @Column(name = "pwd")
+    private String pwd;
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getUserName() {
+        return userName;
+    }
+    
+    public void setUserName(final String userName) {
+        this.userName = userName;
+    }
+    
+    public String getPwd() {
+        return pwd;
+    }
+    
+    public void setPwd(final String pwd) {
+        this.pwd = pwd;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("user_id: %d, user_name: %s, pwd: %s", userId, 
userName, pwd);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/application.xml
similarity index 63%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/application.xml
index 72e55aa..f291cb0 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/application.xml
@@ -25,6 +25,7 @@
        
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
        
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
        
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt";
+       
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
@@ -39,16 +40,17 @@
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan 
base-package="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}"/>
-<#if framework=="spring-namespace-jpa">
+    <context:component-scan 
base-package="org.apache.shardingsphere.example.shadow.spring.namespace.jpa"/>
     <bean id="entityManagerFactory" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
         <property name="dataSource" ref="dataSource" />
         <property name="jpaVendorAdapter">
             <bean 
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
p:database="MYSQL" />
         </property>
-        <property name="packagesToScan" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity" />
+        <property name="packagesToScan" 
value="org.apache.shardingsphere.example.shadow.spring.namespace.jpa.entity" />
         <property name="jpaProperties">
             <props>
                 <prop 
key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
@@ -59,43 +61,67 @@
     </bean>
     <bean id="transactionManager" 
class="org.springframework.orm.jpa.JpaTransactionManager" 
p:entityManagerFactory-ref="entityManagerFactory" />
     <tx:annotation-driven />
-</#if>
     
     <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:3307/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
+        <property name="password" value="root"/>
     </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:3307/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
+        <property name="password" value="root"/>
     </bean>
-<#if feature=="sharding">
-    <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-    <#include "readwriteSplittingApplication.ftl">
-<#elseif feature=="encrypt">
-    <#include "encryptApplication.ftl">
-</#if>
-    
-<#if framework=="spring-namespace-mybatis">
-    <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource" ref="dataSource" />
-    </bean>
-    <tx:annotation-driven />
 
-    <bean id="sqlSessionFactory" 
class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource"/>
-        <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
-    </bean>
+    <shadow:shadow-algorithm id="user-id-insert-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">insert</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
 
-    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository"/>
-        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
-    </bean>
-</#if>
+    <shadow:shadow-algorithm id="user-id-delete-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">delete</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-select-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">select</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="simple-hint-algorithm" type="SIMPLE_HINT">
+        <props>
+            <prop key="shadow">true</prop>
+            <prop key="foo">bar</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:rule id="shadowRule" enable="true">
+        <shadow:data-source id="shadow-data-source" 
source-data-source-name="demo_ds_0" shadow-data-source-name="demo_ds_1"/>
+        <shadow:shadow-table name="t_user" data-sources="shadow-data-source">
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-insert-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-delete-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-select-match-algorithm" />
+            <shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
+        </shadow:shadow-table>
+    </shadow:rule>
+
+    <shardingsphere:data-source id="dataSource" 
data-source-names="demo_ds_0,demo_ds_1" rule-refs="shadowRule">
+        <props>
+            <prop key="sql-show">true</prop>
+            <prop key="sql-comment-parse-enabled">true</prop>
+        </props>
+    </shardingsphere:data-source>
+    
 </beans>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/logback.xml
similarity index 56%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/logback.xml
index 3263f28..154abba 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example/src/main/resources/logback.xml
@@ -1,4 +1,5 @@
-<#--
+<?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.
@@ -14,8 +15,20 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<#if feature=="encrypt">
-    <#include "encryptExampleService.ftl">
-<#else>
-    <#include "otherExampleService.ftl">
-</#if>
\ No newline at end of file
+
+<configuration>
+    <property name="log.context.name" value="shardingsphere-example" />
+    <property name="log.charset" value="UTF-8" />
+    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] 
%msg %n" />
+    <contextName>${log.context.name}</contextName>
+    
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namesp
 [...]
similarity index 67%
copy from 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
index 8b6e657..3b45368 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-jdbc-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
@@ -25,14 +25,29 @@
         <version>${revision}</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    
<artifactId>shardingsphere-jdbc-memory-local-shadow-jdbc-example</artifactId>
+    
<artifactId>shardingsphere-jdbc-memory-local-shadow-sping-namespace-mybatis-example</artifactId>
     <name>${project.artifactId}</name>
     
     <dependencies>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-jdbc-core</artifactId>
+            <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-orm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
         </dependency>
     </dependencies>
     
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSp
 [...]
similarity index 52%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSpringNamespaceMybatisExample.java
index afbde72..7b38a89 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSpringNamespaceMybatisExample.java
@@ -15,25 +15,18 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.shadow.spring.namespace.mybatis;
 
-import org.apache.ibatis.annotations.Mapper;
-import 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.sql.SQLException;
 
-import java.util.List;
-
-@Mapper
-public interface OrderItemRepository {
-    
-    void createTableIfNotExists();
-    
-    void truncateTable();
-    
-    void dropTable();
-    
-    void insert(OrderItem orderItem);
-    
-    void delete(long orderId);
+public class MemoryLocalShadowSpringNamespaceMybatisExample {
     
-    List<OrderItem> selectAll();
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = new 
ClassPathXmlApplicationContext("application.xml")) {
+            MemoryLocalShadowSpringNamespaceMybatisExampleService 
exampleService = 
applicationContext.getBean(MemoryLocalShadowSpringNamespaceMybatisExampleService.class);
+            exampleService.run();
+        }
+    }
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSpringNam
 [...]
similarity index 54%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherExampleService.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSpringNamespaceMybatisExampleService.java
index c6e82ad..03a3fb7 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/otherExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/MemoryLocalShadowSpringNamespaceMybatisExampleService.java
@@ -15,34 +15,47 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.shadow.spring.namespace.mybatis;
 
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.entity.User;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.repository.UserRepository;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
 @Service
-public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
-    
+public final class MemoryLocalShadowSpringNamespaceMybatisExampleService {
+
     @Resource
-    private 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 repository;
+    private UserRepository userRepository;
 
     /**
      * Execute test.
+     *
+     * @throws SQLException
      */
     public void run() {
+        try {
+            this.initEnvironment();
+            this.processSuccess();
+        } finally {
+            this.cleanEnvironment();
+        }
+    }
+    
+    /**
+     * Initialize the database test environment.
+     * @throws SQLException
+     */
+    private void initEnvironment() {
+        userRepository.createTableIfNotExists();
+        userRepository.truncateTable();
+    }
+    
+    private void processSuccess() {
         System.out.println("-------------- Process Success Begin 
---------------");
         List<Long> orderIds = insertData();
         printData(); 
@@ -55,17 +68,12 @@ public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${fram
         System.out.println("---------------------------- Insert Data 
----------------------------");
         List<Long> result = new ArrayList<>(10);
         for (int i = 1; i <= 10; i++) {
-            Order order = new Order();
-            order.setUserId(i);
-            order.setAddressId(i);
-            order.setStatus("INSERT_TEST");
-            repository.insertOrder(order);
-            OrderItem orderItem = new OrderItem();
-            orderItem.setOrderId(order.getOrderId());
-            orderItem.setUserId(i);
-            orderItem.setStatus("INSERT_TEST");
-            repository.insertOrderItem(orderItem);
-            result.add(order.getOrderId());
+            User user = new User();
+            user.setUserId(i);
+            user.setUserName("test_mybatis_" + i);
+            user.setPwd("pwd_mybatis_" + i);
+            userRepository.insert(user);
+            result.add((long) user.getUserId());
         }
         return result;
     }
@@ -73,19 +81,23 @@ public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${fram
     private void deleteData(final List<Long> orderIds) {
         System.out.println("---------------------------- Delete Data 
----------------------------");
         for (Long each : orderIds) {
-            repository.deleteOrder(each);
-            repository.deleteOrderItem(each);
+            userRepository.delete(each);
         }
     }
     
     private void printData() {
         System.out.println("---------------------------- Print Order Data 
-----------------------");
-        for (Object each : repository.selectAllOrder()) {
-            System.out.println(each);
-        }
-        System.out.println("---------------------------- Print OrderItem Data 
-------------------");
-        for (Object each : repository.selectAllOrderItem()) {
+        for (Object each : userRepository.selectAll()) {
             System.out.println(each);
         }
     }
+    
+    /**
+     * Restore the environment.
+     * @throws SQLException
+     */
+    private void cleanEnvironment() {
+        userRepository.dropTable();
+    }
+
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/entity/User.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-
 [...]
new file mode 100644
index 0000000..d596fee
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/entity/User.java
@@ -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.
+ */
+
+package 
org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+    
+    private static final long serialVersionUID = 263434701950670170L;
+    
+    private int userId;
+
+    private String userName;
+
+    private String pwd;
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getUserName() {
+        return userName;
+    }
+    
+    public void setUserName(final String userName) {
+        this.userName = userName;
+    }
+    
+    public String getPwd() {
+        return pwd;
+    }
+    
+    public void setPwd(final String pwd) {
+        this.pwd = pwd;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("user_id: %d, user_name: %s, pwd: %s", userId, 
userName, pwd);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/repository/UserRepo
 [...]
similarity index 75%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/repository/UserRepository.java
index afbde72..918a0d5 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/repository/OrderItemRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/namespace/mybatis/repository/UserRepository.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package 
org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.repository;
 
 import org.apache.ibatis.annotations.Mapper;
-import 
org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem;
+import 
org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.entity.User;
 
 import java.util.List;
 
 @Mapper
-public interface OrderItemRepository {
+public interface UserRepository {
     
     void createTableIfNotExists();
     
@@ -31,9 +31,9 @@ public interface OrderItemRepository {
     
     void dropTable();
     
-    void insert(OrderItem orderItem);
+    void insert(User user);
     
-    void delete(long orderId);
+    void delete(long userId);
     
-    List<OrderItem> selectAll();
+    List<User> selectAll();
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/application.xml
similarity index 62%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/application.xml
index 72e55aa..5a14e03 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/application.xml
@@ -25,6 +25,7 @@
        
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
        
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
        
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt";
+       
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
@@ -39,50 +40,74 @@
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow
+                           
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan 
base-package="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}"/>
-<#if framework=="spring-namespace-jpa">
-    <bean id="entityManagerFactory" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="jpaVendorAdapter">
-            <bean 
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
p:database="MYSQL" />
-        </property>
-        <property name="packagesToScan" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity" />
-        <property name="jpaProperties">
-            <props>
-                <prop 
key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
-                <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
-                <prop key="hibernate.show_sql">false</prop>
-            </props>
-        </property>
-    </bean>
-    <bean id="transactionManager" 
class="org.springframework.orm.jpa.JpaTransactionManager" 
p:entityManagerFactory-ref="entityManagerFactory" />
-    <tx:annotation-driven />
-</#if>
+    <context:component-scan 
base-package="org.apache.shardingsphere.example.shadow.spring.namespace.mybatis"/>
     
     <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:3307/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
+        <property name="password" value="root"/>
     </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:3307/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
+        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="username" value="root"/>
-        <property name="password" value="123456"/>
+        <property name="password" value="root"/>
     </bean>
-<#if feature=="sharding">
-    <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-    <#include "readwriteSplittingApplication.ftl">
-<#elseif feature=="encrypt">
-    <#include "encryptApplication.ftl">
-</#if>
+
+    <shadow:shadow-algorithm id="user-id-insert-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">insert</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-delete-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">delete</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="user-id-select-match-algorithm" 
type="VALUE_MATCH">
+        <props>
+            <prop key="operation">select</prop>
+            <prop key="column">user_type</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:shadow-algorithm id="simple-hint-algorithm" type="SIMPLE_HINT">
+        <props>
+            <prop key="shadow">true</prop>
+            <prop key="foo">bar</prop>
+        </props>
+    </shadow:shadow-algorithm>
+
+    <shadow:rule id="shadowRule" enable="true">
+        <shadow:data-source id="shadow-data-source" 
source-data-source-name="demo_ds_0" shadow-data-source-name="demo_ds_1"/>
+        <shadow:shadow-table name="t_user" data-sources="shadow-data-source">
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-insert-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-delete-match-algorithm" />
+            <shadow:algorithm 
shadow-algorithm-ref="user-id-select-match-algorithm" />
+            <shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
+        </shadow:shadow-table>
+    </shadow:rule>
+
+    <shardingsphere:data-source id="dataSource" 
data-source-names="demo_ds_0,demo_ds_1" rule-refs="shadowRule">
+        <props>
+            <prop key="sql-show">true</prop>
+            <prop key="sql-comment-parse-enabled">true</prop>
+        </props>
+    </shardingsphere:data-source>
     
-<#if framework=="spring-namespace-mybatis">
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="dataSource" />
     </bean>
@@ -94,8 +119,7 @@
     </bean>
 
     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
value="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository"/>
+        <property name="basePackage" 
value="org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.repository"/>
         <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
     </bean>
-</#if>
 </beans>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/logback.xml
similarity index 56%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/logback.xml
index 3263f28..154abba 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/logback.xml
@@ -1,4 +1,5 @@
-<#--
+<?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.
@@ -14,8 +15,20 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<#if feature=="encrypt">
-    <#include "encryptExampleService.ftl">
-<#else>
-    <#include "otherExampleService.ftl">
-</#if>
\ No newline at end of file
+
+<configuration>
+    <property name="log.context.name" value="shardingsphere-example" />
+    <property name="log.charset" value="UTF-8" />
+    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] 
%msg %n" />
+    <contextName>${log.context.name}</contextName>
+    
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/mappers/UserMapper.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example
 [...]
new file mode 100644
index 0000000..e1e240f
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/src/main/resources/mappers/UserMapper.xml
@@ -0,0 +1,51 @@
+<?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 mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.repository.UserRepository">
+    <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.shadow.spring.namespace.mybatis.entity.User">
+        <result column="user_id" property="userId" jdbcType="INTEGER"/>
+        <result column="user_name" property="userName" jdbcType="VARCHAR"/>
+        <result column="pwd" property="pwd" jdbcType="VARCHAR"/>
+        <result column="assisted_query_pwd" property="assistedQueryPwd" 
jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <update id="createTableIfNotExists">
+        CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL 
AUTO_INCREMENT, user_name VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY 
(user_id));
+    </update>
+
+    <update id="truncateTable">
+        TRUNCATE TABLE t_user;
+    </update>
+
+    <update id="dropTable">
+        DROP TABLE IF EXISTS t_user;
+    </update>
+
+    <insert id="insert">
+        INSERT INTO t_user (user_id, user_name, pwd) VALUES 
(#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, 
#{pwd,jdbcType=VARCHAR})
+    </insert>
+
+    <delete id="delete">
+        DELETE FROM t_user WHERE user_id = #{userId,jdbcType=INTEGER};
+    </delete>
+
+    <select id="selectAll" resultMap="baseResultMap">
+        SELECT * FROM t_user;
+    </select>
+</mapper>

Reply via email to