You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/11/08 07:10:03 UTC

[shardingsphere] branch master updated: Adjust the generators and add spring-namespace related generators (#13481)

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 73660be  Adjust the generators and add spring-namespace related generators (#13481)
73660be is described below

commit 73660be0ed8066fd18dce1ff80ac5fbd31b007c1
Author: Guocheng Tang <to...@qq.com>
AuthorDate: Mon Nov 8 15:09:24 2021 +0800

    Adjust the generators and add spring-namespace related generators (#13481)
    
    * Adjust the generators and add spring-namespace related generators
    
    * Add license
    
    * Update comment
---
 .../example/engine/ExampleGenerateEngine.java      |  12 +-
 .../sharding/example/engine/JDBCGenerator.java     |   9 +-
 .../engine/SpringNamespaceJDBCGenerator.java       |   9 +-
 ...rator.java => SpringNamespaceJpaGenerator.java} |  20 ++--
 ...r.java => SpringNamespaceMybatisGenerator.java} |  24 ++--
 .../engine/SpringbootStarterJDBCGenerator.java     |   9 +-
 .../engine/SpringbootStarterJpaGenerator.java      |  13 ++-
 .../engine/SpringbootStarterMybatisGenerator.java  |  13 ++-
 .../{template => dataModel}/jdbc/data-model.yaml   |   0
 .../spring-namespace-jdbc/data-model.yaml          |   0
 .../spring-namespace-jpa}/data-model.yaml          |   2 +-
 .../spring-namespace-mybatis}/data-model.yaml      |   2 +-
 .../springboot-starter-jdbc/data-model.yaml        |   0
 .../springboot-starter-jpa/data-model.yaml         |   0
 .../springboot-starter-mybatis/data-model.yaml     |   0
 .../src/main/resources/template/Example.ftl        |   7 +-
 .../ExampleService.ftl                             |   6 +-
 .../{springboot-starter-jpa => jpa}/Repository.ftl |   6 +-
 .../resources/template/mappers/OrderItemMapper.ftl |   4 +-
 .../resources/template/mappers/OrderMapper.ftl     |   4 +-
 .../OrderItemRepository.ftl                        |   4 +-
 .../OrderRepository.ftl                            |   4 +-
 .../main/resources/template/xml/application.ftl    |  40 ++++++-
 .../pom.xml                                        |   2 +
 .../pom.xml                                        |  38 ++++--
 ...oryLocalShardingSpringNamespaceJpaExample.java} |  29 ++---
 ...lShardingSpringNamespaceJpaExampleService.java} |  14 +--
 ...LocalShardingSpringNamespaceJpaRepository.java} |  12 +-
 .../spring/namespace/jpa/entity/Order.java         |  84 ++++++++++++++
 .../spring/namespace/jpa/entity/OrderItem.java     |  84 ++++++++++++++
 .../src/main/resources/application.xml}            |  25 +++-
 .../src/main/resources/logback.xml                 |  34 ++++++
 .../pom.xml                                        |  35 ++++--
 ...ocalShardingSpringNamespaceMybatisExample.java} |  29 ++---
 ...ardingSpringNamespaceMybatisExampleService.java | 129 +++++++++++++++++++++
 .../spring/namespace/mybatis/entity/Order.java     |  70 +++++++++++
 .../spring/namespace/mybatis/entity/OrderItem.java |  70 +++++++++++
 .../mybatis/repository/OrderItemRepository.java}   |   4 +-
 .../mybatis/repository/OrderRepository.java}       |   4 +-
 .../src/main/resources/application.xml}            |  22 +++-
 .../src/main/resources/logback.xml                 |  34 ++++++
 .../main/resources/mappers/OrderItemMapper.xml}    |   8 +-
 .../src/main/resources/mappers/OrderMapper.xml}    |   8 +-
 43 files changed, 780 insertions(+), 143 deletions(-)

diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
index 74d83ae..24f9531 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
@@ -53,6 +53,8 @@ public abstract class ExampleGenerateEngine {
             "<#assign frameworkName=frameworkName + framework1?cap_first>" +
             "</#list>${frameworkName}";
     
+    private static final String FRAMEWORK_PATH = "/dataModel/%s/data-model.yaml";
+    
     private final Map<String, String> renameTemplateMap;
     
     private final Map<String, String> unRenameTemplateMap;
@@ -100,13 +102,19 @@ public abstract class ExampleGenerateEngine {
         }
         return null;
     }
+
+    /**
+     * get generator.
+     * @return generator name
+     */
+    protected abstract String getGenerator();
     
     /**
      * exec code generate
-     * @param path template relative road strength
      */
-    protected void exec(String path) {
+    protected void exec() {
         Yaml yaml = new Yaml();
+        String path = String.format(FRAMEWORK_PATH, getGenerator());
         InputStream in = ExampleGenerateEngine.class.getResourceAsStream(path);
         Map<String, String> dataModel = yaml.loadAs(in, Map.class);
         this.generateJavaCode(dataModel);
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/JDBCGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/JDBCGenerator.java
index cf7997f..0be2fcb 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/JDBCGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/JDBCGenerator.java
@@ -41,9 +41,14 @@ public final class JDBCGenerator extends ExampleGenerateEngine {
     public JDBCGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "jdbc";
+    }
+    
     public static void main(String[] args) {
         JDBCGenerator generator = new JDBCGenerator();
-        generator.exec("/template/jdbc/data-model.yaml");
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java
index 681295b..9e4574d 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java
@@ -42,9 +42,14 @@ public final class SpringNamespaceJDBCGenerator extends ExampleGenerateEngine {
     public SpringNamespaceJDBCGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "spring-namespace-jdbc";
+    }
+    
     public static void main(String[] args) {
         SpringNamespaceJDBCGenerator generator = new SpringNamespaceJDBCGenerator();
-        generator.exec("/template/spring-namespace-jdbc/data-model.yaml");
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJpaGenerator.java
similarity index 75%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJpaGenerator.java
index 681295b..d8ff8e2 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJDBCGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceJpaGenerator.java
@@ -21,9 +21,9 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * spring namespace jdbc generator.
+ * spring namespace jpa generator.
  */
-public final class SpringNamespaceJDBCGenerator extends ExampleGenerateEngine {
+public final class SpringNamespaceJpaGenerator extends ExampleGenerateEngine {
     
     private static final Map<String, String> RENAME_TEMPLATE_MAP = new HashMap<>();
     private static final Map<String, String> UN_NAME_TEMPLATE_MAP = new HashMap<>();
@@ -31,7 +31,8 @@ public final class SpringNamespaceJDBCGenerator extends ExampleGenerateEngine {
     
     static {
         RENAME_TEMPLATE_MAP.put("Example", "Example.ftl");
-        RENAME_TEMPLATE_MAP.put("ExampleService", "jdbc/ExampleService.ftl");
+        RENAME_TEMPLATE_MAP.put("ExampleService", "jpa/ExampleService.ftl");
+        RENAME_TEMPLATE_MAP.put("Repository", "jpa/Repository.ftl");
         
         UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
         UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
@@ -39,12 +40,17 @@ public final class SpringNamespaceJDBCGenerator extends ExampleGenerateEngine {
         RESOURCE_TEMPLATE_MAP.put("xml/application", "application.xml");
     }
     
-    public SpringNamespaceJDBCGenerator() {
+    public SpringNamespaceJpaGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "spring-namespace-jpa";
+    }
+    
     public static void main(String[] args) {
-        SpringNamespaceJDBCGenerator generator = new SpringNamespaceJDBCGenerator();
-        generator.exec("/template/spring-namespace-jdbc/data-model.yaml");
+        SpringNamespaceJpaGenerator generator = new SpringNamespaceJpaGenerator();
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceMybatisGenerator.java
similarity index 71%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceMybatisGenerator.java
index 09fa859..38fe7e5 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringNamespaceMybatisGenerator.java
@@ -21,9 +21,9 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * spring boot starter mybatis generator.
+ * spring namespace mybatis generator.
  */
-public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngine {
+public final class SpringNamespaceMybatisGenerator extends ExampleGenerateEngine {
     
     private static final Map<String, String> RENAME_TEMPLATE_MAP = new HashMap<>();
     private static final Map<String, String> UN_NAME_TEMPLATE_MAP = new HashMap<>();
@@ -35,19 +35,25 @@ public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngi
         
         UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
         UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
-        UN_NAME_TEMPLATE_MAP.put("springboot-starter-mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
-        UN_NAME_TEMPLATE_MAP.put("springboot-starter-mybatis/OrderRepository", "repository/OrderRepository.java");
+        UN_NAME_TEMPLATE_MAP.put("mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
+        UN_NAME_TEMPLATE_MAP.put("mybatis/OrderRepository", "repository/OrderRepository.java");
 
         RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper", "mappers/OrderItemMapper.xml");
-        RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderItemMapper.xml");
+        RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderMapper.xml");
+        RESOURCE_TEMPLATE_MAP.put("xml/application", "application.xml");
     }
 
-    public SpringbootStarterMybatisGenerator() {
+    public SpringNamespaceMybatisGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "spring-namespace-mybatis";
+    }
+    
     public static void main(String[] args) {
-        SpringbootStarterMybatisGenerator generator = new SpringbootStarterMybatisGenerator();
-        generator.exec("/template/springboot-starter-mybatis/data-model.yaml");
+        SpringNamespaceMybatisGenerator generator = new SpringNamespaceMybatisGenerator();
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
index 15690a7..d1815f0 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
@@ -40,9 +40,14 @@ public final class SpringbootStarterJDBCGenerator extends ExampleGenerateEngine
     public SpringbootStarterJDBCGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "springboot-starter-jdbc";
+    }
+    
     public static void main(String[] args) {
         SpringbootStarterJDBCGenerator generator = new SpringbootStarterJDBCGenerator();
-        generator.exec("/template/springboot-starter-jdbc/data-model.yaml");
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
index 9ad7baa..6e12afe 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
@@ -31,8 +31,8 @@ public final class SpringbootStarterJpaGenerator extends ExampleGenerateEngine {
 
     static {
         RENAME_TEMPLATE_MAP.put("Example", "Example.ftl");
-        RENAME_TEMPLATE_MAP.put("ExampleService", "springboot-starter-jpa/ExampleService.ftl");
-        RENAME_TEMPLATE_MAP.put("Repository", "springboot-starter-jpa/Repository.ftl");
+        RENAME_TEMPLATE_MAP.put("ExampleService", "jpa/ExampleService.ftl");
+        RENAME_TEMPLATE_MAP.put("Repository", "jpa/Repository.ftl");
         
         UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
         UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
@@ -41,9 +41,14 @@ public final class SpringbootStarterJpaGenerator extends ExampleGenerateEngine {
     public SpringbootStarterJpaGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "springboot-starter-jpa";
+    }
+    
     public static void main(String[] args) {
         SpringbootStarterJpaGenerator generator = new SpringbootStarterJpaGenerator();
-        generator.exec("/template/springboot-starter-jpa/data-model.yaml");
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
index 09fa859..90072f1 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
@@ -35,8 +35,8 @@ public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngi
         
         UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
         UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
-        UN_NAME_TEMPLATE_MAP.put("springboot-starter-mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
-        UN_NAME_TEMPLATE_MAP.put("springboot-starter-mybatis/OrderRepository", "repository/OrderRepository.java");
+        UN_NAME_TEMPLATE_MAP.put("mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
+        UN_NAME_TEMPLATE_MAP.put("mybatis/OrderRepository", "repository/OrderRepository.java");
 
         RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper", "mappers/OrderItemMapper.xml");
         RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderItemMapper.xml");
@@ -45,9 +45,14 @@ public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngi
     public SpringbootStarterMybatisGenerator() {
         super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
     }
-
+    
+    @Override
+    protected String getGenerator() {
+        return "springboot-starter-mybatis";
+    }
+    
     public static void main(String[] args) {
         SpringbootStarterMybatisGenerator generator = new SpringbootStarterMybatisGenerator();
-        generator.exec("/template/springboot-starter-mybatis/data-model.yaml");
+        generator.exec();
     }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
similarity index 100%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
similarity index 100%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jdbc/data-model.yaml
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
similarity index 96%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
index c58817d..10fb892 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
@@ -18,5 +18,5 @@
 mode: memory
 transaction: local
 feature: sharding
-framework: spring-namespace-jdbc
+framework: spring-namespace-jpa
 
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
similarity index 95%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
index c58817d..e5ec759 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spring-namespace-jdbc/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
@@ -18,5 +18,5 @@
 mode: memory
 transaction: local
 feature: sharding
-framework: spring-namespace-jdbc
+framework: spring-namespace-mybatis
 
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
similarity index 100%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jdbc/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
similarity index 100%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
similarity index 100%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
index 35beadf..53d91c9 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
@@ -16,8 +16,8 @@
  */
 
 package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
-<#if framework?contains("springboot")>
 
+<#if framework?contains("springboot")>
 <#if framework=="springboot-starter-mybatis">
 import org.mybatis.spring.annotation.MapperScan;
 <#elseif framework=="springboot-starter-jpa">
@@ -26,14 +26,13 @@ import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ConfigurableApplicationContext;
-<#elseif framework=="spring-namespace-jdbc">
+<#elseif framework?contains("spring-namespace")>
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 <#elseif framework=="jdbc">
 
 import javax.sql.DataSource;
 </#if>
-
 import java.sql.SQLException;
 
 <#assign frameworkName="">
@@ -58,7 +57,7 @@ public class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${fram
         ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}ExampleService exampleService = new ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}ExampleService(dataSource);
         exampleService.run();
     <#else>
-    <#if framework=="spring-namespace-jdbc">
+    <#if framework?contains("spring-namespace")>
         try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml")) {
     <#else>
         try (ConfigurableApplicationContext applicationContext = SpringApplication.run(${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Example.class, args)) {
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
similarity index 91%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
index a005010..924821c 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.jpa;
+package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
 
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.Order;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
similarity index 89%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
index 1c31a2c..0aaebfa 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.jpa;
+package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
 
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.Order;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
 import org.springframework.stereotype.Repository;
 
 import javax.persistence.EntityManager;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
index 15818e6..d901a06 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
@@ -17,8 +17,8 @@
   -->
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository.OrderItemRepository">
-    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem">
+<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository">
+    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem">
         <result column="order_item_id" property="orderItemId" jdbcType="INTEGER"/>
         <result column="order_id" property="orderId" jdbcType="INTEGER"/>
         <result column="user_id" property="userId" jdbcType="INTEGER"/>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
index 7326504..b089fcc 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
@@ -17,8 +17,8 @@
   -->
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository.OrderRepository">
-    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.Order">
+<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository">
+    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order">
         <result column="order_id" property="orderId" jdbcType="BIGINT"/>
         <result column="user_id" property="userId" jdbcType="INTEGER"/>
         <result column="address_id" property="addressId" jdbcType="BIGINT"/>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
similarity index 85%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
index afbde72..946298e 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
 
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
 
 import java.util.List;
 
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
similarity index 85%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
index 28d0500..ad58a50 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
 
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.Order;
+import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
 
 import java.util.List;
 
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 e5eb807..03d0c63 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
@@ -18,20 +18,42 @@
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
        xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/tx
+                           http://www.springframework.org/schema/tx/spring-tx.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan base-package="org.apache.shardingsphere.example.${feature}.spring.namespace.jdbc"/>
+    <context:component-scan base-package="org.apache.shardingsphere.example.${feature}.${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}.${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>
     
     <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
@@ -79,4 +101,20 @@
     </sharding:rule>
     
     <shardingsphere:data-source id="dataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
+<#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>
+
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="basePackage" value="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository"/>
+        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
+    </bean>
+</#if>
 </beans>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
index 48e3286..2b011de 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
@@ -34,6 +34,8 @@
         <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example</module>
         <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jpa-example</module>
         <module>shardingsphere-jdbc-memory-local-sharding-spring-namespace-jdbc-example</module>
+        <module>shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example</module>
+        <module>shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-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-sharding-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/pom.xml
similarity index 53%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/pom.xml
index 48e3286..8e0b60d 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/pom.xml
@@ -20,20 +20,38 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+        <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
         <groupId>org.apache.shardingsphere.example</groupId>
         <version>5.0.0-RC1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
+    <artifactId>shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example</artifactId>
     <name>${project.artifactId}</name>
     
-    <modules>
-        <module>shardingsphere-jdbc-memory-local-sharding-jdbc-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jpa-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-spring-namespace-jdbc-example</module>
-    </modules>
-    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <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>
 </project>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/Memor [...]
similarity index 53%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaExample.java
index afbde72..2600884 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaExample.java
@@ -15,25 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.sharding.spring.namespace.jpa;
 
-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 MemoryLocalShardingSpringNamespaceJpaExample {
     
-    List<OrderItem> selectAll();
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml")) {
+            MemoryLocalShardingSpringNamespaceJpaExampleService exampleService = applicationContext.getBean(MemoryLocalShardingSpringNamespaceJpaExampleService.class);
+            exampleService.run();
+        }
+    }
 }
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalSha [...]
similarity index 81%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl
rename to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaExampleService.java
index a005010..1ce384c 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaExampleService.java
@@ -15,25 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.jpa;
+package org.apache.shardingsphere.example.sharding.spring.namespace.jpa;
 
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.Order;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.OrderItem;
+import org.apache.shardingsphere.example.sharding.spring.namespace.jpa.entity.Order;
+import org.apache.shardingsphere.example.sharding.spring.namespace.jpa.entity.OrderItem;
 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>
 @Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class MemoryLocalShardingSpringNamespaceJpaExampleService {
     
     @Resource
-    private ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository repository;
+    private MemoryLocalShardingSpringNamespaceJpaRepository repository;
 
     /**
      * Execute test.
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardin [...]
similarity index 81%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl
rename to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaRepository.java
index 1c31a2c..1428f3b 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-jpa/Repository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/MemoryLocalShardingSpringNamespaceJpaRepository.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.jpa;
+package org.apache.shardingsphere.example.sharding.spring.namespace.jpa;
 
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.Order;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity.OrderItem;
+import org.apache.shardingsphere.example.sharding.spring.namespace.jpa.entity.Order;
+import org.apache.shardingsphere.example.sharding.spring.namespace.jpa.entity.OrderItem;
 import org.springframework.stereotype.Repository;
 
 import javax.persistence.EntityManager;
@@ -27,13 +27,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>
 @Repository
 @Transactional
-public class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository {
+public class MemoryLocalShardingSpringNamespaceJpaRepository {
     
     @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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-e [...]
new file mode 100644
index 0000000..dc706fe
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/entity/Order.java
@@ -0,0 +1,84 @@
+/*
+ * 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.sharding.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_order")
+public class Order implements Serializable {
+    
+    private static final long serialVersionUID = 8306802022239174861L;
+    
+    @Id
+    @Column(name = "order_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long orderId;
+    
+    @Column(name = "user_id")
+    private int userId;
+    
+    @Column(name = "address_id")
+    private long addressId;
+    
+    @Column(name = "status")
+    private String status;
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    public long getAddressId() {
+        return addressId;
+    }
+    
+    public void setAddressId(final long addressId) {
+        this.addressId = addressId;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+    }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-loc [...]
new file mode 100644
index 0000000..397e327
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/entity/OrderItem.java
@@ -0,0 +1,84 @@
+/*
+ * 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.sharding.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_order_item")
+public class OrderItem implements Serializable {
+    
+    private static final long serialVersionUID = 1332162822494069342L;
+    
+    @Id
+    @Column(name = "order_item_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long orderItemId;
+    
+    @Column(name = "order_id")
+    private long orderId;
+    
+    @Column(name = "user_id")
+    private int userId;
+    
+    @Column(name = "status")
+    private String status;
+    
+    public long getOrderItemId() {
+        return orderItemId;
+    }
+    
+    public void setOrderItemId(final long orderItemId) {
+        this.orderItemId = orderItemId;
+    }
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+    }
+}
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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/resources/application.xml
similarity index 77%
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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/resources/application.xml
index e5eb807..2b6e93d 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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/resources/application.xml
@@ -18,20 +18,41 @@
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
        xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/tx
+                           http://www.springframework.org/schema/tx/spring-tx.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan base-package="org.apache.shardingsphere.example.${feature}.spring.namespace.jdbc"/>
+    <context:component-scan base-package="org.apache.shardingsphere.example.sharding.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.sharding.spring.namespace.jpa.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 />
     
     <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
@@ -49,7 +70,7 @@
 
     <sharding:sharding-algorithm id="databaseAlgorithm" type="INLINE">
         <props>
-            <prop key="algorithm-expression">demo_ds_${r'${user_id % 2}'}</prop>
+            <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
         </props>
     </sharding:sharding-algorithm>
     <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/resources/logback.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/sharding [...]
new file mode 100644
index 0000000..1c4b005
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-jpa-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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.
+  -->
+
+<configuration>
+    <property name="log.context.name" value="shardingsphere-example-engine" />
+    <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-sharding-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/pom.xml
similarity index 58%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/pom.xml
index 48e3286..4d0370c 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/pom.xml
@@ -20,20 +20,33 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+        <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
         <groupId>org.apache.shardingsphere.example</groupId>
         <version>5.0.0-RC1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
+    <artifactId>shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example</artifactId>
     <name>${project.artifactId}</name>
-    
-    <modules>
-        <module>shardingsphere-jdbc-memory-local-sharding-jdbc-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-springboot-starter-jpa-example</module>
-        <module>shardingsphere-jdbc-memory-local-sharding-spring-namespace-jdbc-example</module>
-    </modules>
-    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <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>
 </project>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybat [...]
similarity index 52%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/MemoryLocalShardingSpringNamespaceMybatisExample.java
index afbde72..e89b365 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/MemoryLocalShardingSpringNamespaceMybatisExample.java
@@ -15,25 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.sharding.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 MemoryLocalShardingSpringNamespaceMybatisExample {
     
-    List<OrderItem> selectAll();
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml")) {
+            MemoryLocalShardingSpringNamespaceMybatisExampleService exampleService = applicationContext.getBean(MemoryLocalShardingSpringNamespaceMybatisExampleService.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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/MemoryLocalShardingSpringNamespaceMybatisExampleService.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdb [...]
new file mode 100644
index 0000000..2c10400
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/MemoryLocalShardingSpringNamespaceMybatisExampleService.java
@@ -0,0 +1,129 @@
+/*
+ * 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.sharding.spring.namespace.mybatis;
+
+import org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.entity.Order;
+import org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.entity.OrderItem;
+import org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderItemRepository;
+import org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderRepository;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalShardingSpringNamespaceMybatisExampleService {
+    
+    @Resource
+    private OrderRepository orderRepository;
+    
+    @Resource
+    private OrderItemRepository orderItemRepository;
+
+    /**
+     * 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() {
+        orderRepository.createTableIfNotExists();
+        orderItemRepository.createTableIfNotExists();
+        orderRepository.truncateTable();
+        orderItemRepository.truncateTable();
+    }
+    
+    private void processSuccess() {
+        System.out.println("-------------- Process Success Begin ---------------");
+        List<Long> orderIds = insertData();
+        printData(); 
+        deleteData(orderIds);
+        printData();
+        System.out.println("-------------- Process Success Finish --------------");
+    }
+
+    private List<Long> insertData() {
+        System.out.println("---------------------------- Insert Data ----------------------------");
+        List<Long> result = new ArrayList<>(10);
+        for (int i = 1; i <= 10; i++) {
+            Order order = insertOrder(i);
+            insertOrderItem(i, order);
+            result.add(order.getOrderId());
+        }
+        return result;
+    }
+    
+    private Order insertOrder(final int i) {
+        Order order = new Order();
+        order.setUserId(i);
+        order.setAddressId(i);
+        order.setStatus("INSERT_TEST");
+        orderRepository.insert(order);
+        return order;
+    }
+
+    private void insertOrderItem(final int i, final Order order) {
+        OrderItem orderItem = new OrderItem();
+        orderItem.setOrderId(order.getOrderId());
+        orderItem.setUserId(i);
+        orderItem.setStatus("INSERT_TEST");
+        orderItemRepository.insert(orderItem);
+    }
+
+    private void deleteData(final List<Long> orderIds) {
+        System.out.println("---------------------------- Delete Data ----------------------------");
+        for (Long each : orderIds) {
+            orderRepository.delete(each);
+            orderItemRepository.delete(each);
+        }
+    }
+    
+    private void printData() {
+        System.out.println("---------------------------- Print Order Data -----------------------");
+        for (Object each : orderRepository.selectAll()) {
+            System.out.println(each);
+        }
+        System.out.println("---------------------------- Print OrderItem Data -------------------");
+        for (Object each : orderItemRepository.selectAll()) {
+            System.out.println(each);
+        }
+    }
+    
+    /**
+     * Restore the environment.
+     * @throws SQLException
+     */
+    private void cleanEnvironment() {
+        orderRepository.dropTable();
+        orderItemRepository.dropTable();
+    }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory [...]
new file mode 100644
index 0000000..02d9657
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/entity/Order.java
@@ -0,0 +1,70 @@
+/*
+ * 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.sharding.spring.namespace.mybatis.entity;
+
+import java.io.Serializable;
+
+public class Order implements Serializable {
+    
+    private static final long serialVersionUID = 8306802022239174861L;
+    
+    private long orderId;
+    
+    private int userId;
+    
+    private long addressId;
+    
+    private String status;
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    public long getAddressId() {
+        return addressId;
+    }
+    
+    public void setAddressId(final long addressId) {
+        this.addressId = addressId;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+    }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-me [...]
new file mode 100644
index 0000000..73beae7
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/entity/OrderItem.java
@@ -0,0 +1,70 @@
+/*
+ * 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.sharding.spring.namespace.mybatis.entity;
+
+import java.io.Serializable;
+
+public class OrderItem implements Serializable {
+    
+    private static final long serialVersionUID = 1332162822494069342L;
+    
+    private long orderItemId;
+    
+    private long orderId;
+    
+    private int userId;
+    
+    private String status;
+    
+    public long getOrderItemId() {
+        return orderItemId;
+    }
+    
+    public void setOrderItemId(final long orderItemId) {
+        this.orderItemId = orderItemId;
+    }
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+    }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybat [...]
similarity index 85%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
rename to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/repository/OrderItemRepository.java
index afbde72..c871b0d 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/repository/OrderItemRepository.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.sharding.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.sharding.spring.namespace.mybatis.entity.OrderItem;
 
 import java.util.List;
 
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/r [...]
similarity index 85%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl
rename to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/repository/OrderRepository.java
index 28d0500..8ff5359 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/springboot-starter-mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/repository/OrderRepository.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository;
+package org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository;
 
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.Order;
+import org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.entity.Order;
 
 import java.util.List;
 
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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/application.xml
similarity index 81%
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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/application.xml
index e5eb807..494ff5b 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-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/application.xml
@@ -18,20 +18,24 @@
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
        xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/tx
+                           http://www.springframework.org/schema/tx/spring-tx.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource
                            http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding
                            http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
                            ">
     <context:annotation-config />
-    <context:component-scan base-package="org.apache.shardingsphere.example.${feature}.spring.namespace.jdbc"/>
+    <context:component-scan base-package="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis"/>
     
     <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
@@ -49,7 +53,7 @@
 
     <sharding:sharding-algorithm id="databaseAlgorithm" type="INLINE">
         <props>
-            <prop key="algorithm-expression">demo_ds_${r'${user_id % 2}'}</prop>
+            <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
         </props>
     </sharding:sharding-algorithm>
     <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
@@ -79,4 +83,18 @@
     </sharding:rule>
     
     <shardingsphere:data-source id="dataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
+    <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>
+
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="basePackage" value="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository"/>
+        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
+    </bean>
 </beans>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/logback.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shar [...]
new file mode 100644
index 0000000..1c4b005
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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.
+  -->
+
+<configuration>
+    <property name="log.context.name" value="shardingsphere-example-engine" />
+    <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-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
index 15818e6..7a3b06c 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
@@ -17,8 +17,8 @@
   -->
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository.OrderItemRepository">
-    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.OrderItem">
+<mapper namespace="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderItemRepository">
+    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.entity.OrderItem">
         <result column="order_item_id" property="orderItemId" jdbcType="INTEGER"/>
         <result column="order_id" property="orderId" jdbcType="INTEGER"/>
         <result column="user_id" property="userId" jdbcType="INTEGER"/>
@@ -38,11 +38,11 @@
     </update>
     
     <insert id="insert" useGeneratedKeys="true" keyProperty="orderItemId">
-        INSERT INTO t_order_item (order_id, user_id, status) VALUES (${r"#{orderId,jdbcType=INTEGER}"}, ${r"#{userId,jdbcType=INTEGER}"}, ${r"#{status,jdbcType=VARCHAR}"});
+        INSERT INTO t_order_item (order_id, user_id, status) VALUES (#{orderId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR});
     </insert>
     
     <delete id="delete">
-        DELETE FROM t_order_item WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+        DELETE FROM t_order_item WHERE order_id = #{orderId,jdbcType=INTEGER};
     </delete>
     
     <select id="selectAll" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
index 7326504..7ece991 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
@@ -17,8 +17,8 @@
   -->
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository.OrderRepository">
-    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.entity.Order">
+<mapper namespace="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderRepository">
+    <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.entity.Order">
         <result column="order_id" property="orderId" jdbcType="BIGINT"/>
         <result column="user_id" property="userId" jdbcType="INTEGER"/>
         <result column="address_id" property="addressId" jdbcType="BIGINT"/>
@@ -38,11 +38,11 @@
     </update>
     
     <insert id="insert" useGeneratedKeys="true" keyProperty="orderId">
-        INSERT INTO t_order (user_id, address_id, status) VALUES (${r"#{userId,jdbcType=INTEGER}"}, ${r"#{addressId,jdbcType=BIGINT}"}, ${r"#{status,jdbcType=VARCHAR}"});
+        INSERT INTO t_order (user_id, address_id, status) VALUES (#{userId,jdbcType=INTEGER}, #{addressId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR});
     </insert>
     
     <delete id="delete">
-        DELETE FROM t_order WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+        DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER};
     </delete>
     
     <select id="selectAll" resultMap="baseResultMap">