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 debf19a  Adjust the template directory structure and unify template 
(#14555)
debf19a is described below

commit debf19a37e7d1293daee0e157f6af4d2a8d2e68a
Author: Guocheng Tang <[email protected]>
AuthorDate: Thu Jan 6 02:08:12 2022 +0800

    Adjust the template directory structure and unify template (#14555)
    
    * Adjust the template directory structure
    
    * Adjust unified template
---
 .../example/engine/ExampleTemplateFactory.java     |   2 +-
 .../src/main/resources/template/ExampleService.ftl |  78 ----------
 .../main/resources/template/{ => java}/Example.ftl |   0
 .../resources/template/java/ExampleService.ftl     | 159 +++++++++++++++++++++
 .../TestQueryAssistedShardingEncryptAlgorithm.ftl  |   0
 .../{jdbc => java/config}/ExampleService.ftl       |   0
 .../{jdbc => java/config}/configuration.ftl        |   0
 .../{jdbc => java/config}/db-discovery.ftl         |   0
 .../template/{jdbc => java/config}/encrypt.ftl     |   0
 .../{jdbc => java/config}/readwrite-splitting.ftl  |   0
 .../template/{jdbc => java/config}/shadow.ftl      |   0
 .../template/{jdbc => java/config}/sharding.ftl    |   0
 .../resources/template/{ => java}/entity/Order.ftl |   0
 .../template/{ => java}/entity/OrderItem.ftl       |   0
 .../java/repository/jdbc/OrderItemRepository.ftl   | 138 ++++++++++++++++++
 .../java/repository/jdbc/OrderRepository.ftl       | 142 ++++++++++++++++++
 .../repository/jpa/OrderItemRepository.ftl}        |  48 ++++---
 .../repository/jpa/OrderRepository.ftl}            |  48 ++++---
 .../repository}/mybatis/OrderItemRepository.ftl    |   8 ++
 .../repository}/mybatis/OrderRepository.ftl        |  22 ++-
 .../main/resources/template/jpa/ExampleService.ftl |  52 -------
 .../resources/template/jpa/orderExampleService.ftl |  66 ---------
 .../resources/template/jpa/orderRepository.ftl     |  46 ------
 .../template/jpa/shadowExampleService.ftl          |  60 --------
 .../resources/template/jpa/shadowJpaRepository.ftl |  34 -----
 .../resources/template/jpa/userExampleService.ftl  |  55 -------
 .../main/resources/template/jpa/userRepository.ftl |  32 -----
 .../resources/template/mybatis/UserRepository.ftl  |  39 -----
 .../template/mybatis/mappers/UserMapper.ftl        |  51 -------
 .../template/mybatis/mappers/shadowUserMapper.ftl  |  67 ---------
 .../template/mybatis/shadowUserRepository.ftl      |  73 ----------
 .../resources/template/orderExampleService.ftl     |  93 ------------
 .../template/{log => resources}/logback.ftl        |   0
 .../mappers/OrderItemMapper.ftl                    |  19 ++-
 .../{mybatis => resources}/mappers/OrderMapper.ftl |  19 ++-
 .../{ => resources}/properties/application.ftl     |   0
 .../{ => resources}/properties/db-discovery.ftl    |   0
 .../{ => resources}/properties/encrypt.ftl         |   0
 .../properties/readwrite-splitting.ftl             |   0
 .../template/{ => resources}/properties/shadow.ftl |   0
 .../{ => resources}/properties/sharding.ftl        |   0
 .../{ => resources}/spi/encryptAlgorithm.ftl       |   0
 .../template/{ => resources}/xml/application.ftl   |   0
 .../template/{ => resources}/xml/db-discovery.ftl  |   0
 .../template/{ => resources}/xml/encrypt.ftl       |   0
 .../{ => resources}/xml/readwrite-splitting.ftl    |   0
 .../template/{ => resources}/xml/shadow.ftl        |   0
 .../template/{ => resources}/xml/sharding.ftl      |   0
 .../template/shadowUserExampleService.ftl          |  71 ---------
 .../main/resources/template/userExampleService.ftl |  71 ---------
 50 files changed, 550 insertions(+), 943 deletions(-)

diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/shardingsphere/example/engine/ExampleTemplateFactory.java
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/shardingsphere/example/engine/ExampleTemplateFactory.java
index 740d51f..a16ee17 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/shardingsphere/example/engine/ExampleTemplateFactory.java
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/shardingsphere/example/engine/ExampleTemplateFactory.java
@@ -74,7 +74,7 @@ public final class ExampleTemplateFactory {
         result.put("entity/Order", "entity/Order.java");
         result.put("entity/OrderItem", "entity/OrderItem.java");
         if (framework.contains("mybatis")) {
-            result.put("mybatis/OrderItemRepository", 
"repository/OrderItemRepository.java");
+            result.put("mybatis/OrderItemRepository", 
"repository/OrderItemRepository.ftl");
             result.put("mybatis/OrderRepository", 
"repository/OrderRepository.java");
         }
         return result;
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
deleted file mode 100644
index a7bcafb..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
-
-<#if feature=="encrypt" || feature=="shadow">
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.UserRepository;
-<#else>
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.OrderItemRepository;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.OrderRepository;
-</#if>
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
-@Service
-public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
-
-<#if feature=="encrypt" || feature=="shadow">
-    @Resource
-    private UserRepository userRepository;
-<#else>
-    @Resource
-    private OrderRepository orderRepository;
-    
-    @Resource
-    private OrderItemRepository orderItemRepository;
-</#if>
-
-    /**
-     * Execute test.
-     *
-     * @throws SQLException
-     */
-    public void run() {
-        try {
-            this.initEnvironment();
-            this.processSuccess();
-        } finally {
-            this.cleanEnvironment();
-        }
-    }
-<#if feature=="encrypt">
-    <#include "userExampleService.ftl">
-<#elseif feature=="shadow">
-    <#include "shadowUserExampleService.ftl">
-<#else>
-    <#include "orderExampleService.ftl">
-</#if>
-}
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/java/Example.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/Example.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/ExampleService.ftl
new file mode 100644
index 0000000..1d425c8
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/ExampleService.ftl
@@ -0,0 +1,159 @@
+/*
+ * 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.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.OrderItemRepository;
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.OrderRepository;
+
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+<#assign frameworkName="">
+<#list framework?split("-") as framework1>
+    <#assign frameworkName=frameworkName + framework1?cap_first>
+</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+    <#assign featureName=featureName + feature1?cap_first>
+</#list>
+<#if framework?contains("spring")>
+@Service
+</#if>
+public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
+    
+    private final OrderRepository orderRepository;
+    
+    private final OrderItemRepository orderItemRepository;
+<#if framework?contains("jdbc")>
+    public 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService(final
 DataSource dataSource) {
+        orderRepository = new OrderRepository(dataSource);
+        orderItemRepository = new OrderItemRepository(dataSource);
+    }
+<#else>
+    public 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService(final
 OrderRepository orderRepository,
+                                                                               
                  final OrderItemRepository orderItemRepository) {
+        this.orderRepository = orderRepository;
+        this.orderItemRepository = orderItemRepository;
+    }
+</#if>
+    
+    /**
+     * 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() throws SQLException {
+        orderRepository.createTableIfNotExists();
+        orderItemRepository.createTableIfNotExists();
+        orderRepository.truncateTable();
+        orderItemRepository.truncateTable();
+    <#if feature=="shadow">
+        orderRepository.createTableIfNotExistsShadow();
+        orderRepository.truncateTableShadow();
+    </#if>
+        }
+    }
+    
+    private void processSuccess() throws SQLException {
+        System.out.println("-------------- Process Success Begin 
---------------");
+        List<Long> orderIds = insertData();
+        printData(); 
+        deleteData(orderIds);
+        printData();
+        System.out.println("-------------- Process Success Finish 
--------------");
+    }
+    
+    private List<Long> insertData() throws SQLException {
+        System.out.println("---------------------------- Insert Data 
----------------------------");
+        List<Long> result = new ArrayList<>(10);
+        for (int i = 1; i <= 10; i++) {
+            Order order = new Order();
+            order.setUserId(i);
+            order.setOrderType(i % 2);
+            order.setAddressId(i);
+            order.setStatus("INSERT_TEST");
+            repository.insertOrder(order);
+            OrderItem orderItem = new OrderItem();
+            orderItem.setOrderId(order.getOrderId());
+            orderItem.setUserId(i);
+            orderItem.setPhone("13800000001");
+            orderItem.setStatus("INSERT_TEST");
+            repository.insertOrderItem(orderItem);
+            result.add(order.getOrderId());
+        }
+        return result;
+    }
+    
+    private void deleteData(final List<Long> orderIds) throws SQLException {
+        System.out.println("---------------------------- Delete Data 
----------------------------");
+        for (Long each : orderIds) {
+            orderRepository.delete(each);
+            orderItemRepository.delete(each);
+        }
+    }
+    
+    private void printData() throws SQLException {
+        System.out.println("---------------------------- Print Order Data 
-----------------------");
+        for (Object each : this.selectAll()) {
+            System.out.println(each);
+        }
+        System.out.println("---------------------------- Print OrderItem Data 
-------------------");
+        for (Object each : orderItemRepository.selectAll()) {
+            System.out.println(each);
+        }
+    }
+    
+    private List<Order> selectAll() {
+        List<Order> result = orderRepository.selectAll();
+    <#if feature=="shadow">
+        result.addAll(orderRepository.selectShadowOrder());
+    </#if>
+        return result;
+    }
+    
+    /**
+     * Restore the environment.
+     * @throws SQLException
+     */
+    private void cleanEnvironment() throws SQLException {
+    <#if feature=="shadow">
+        orderRepository.dropTableShadow();
+    </#if>
+        orderRepository.dropTable();
+        orderItemRepository.dropTable();
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/TestQueryAssistedShardingEncryptAlgorithm.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/TestQueryAssistedShardingEncryptAlgorithm.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/TestQueryAssistedShardingEncryptAlgorithm.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/TestQueryAssistedShardingEncryptAlgorithm.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/ExampleService.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/ExampleService.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/configuration.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/configuration.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/configuration.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/configuration.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/db-discovery.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/db-discovery.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/db-discovery.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/db-discovery.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/encrypt.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/encrypt.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/encrypt.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/encrypt.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/readwrite-splitting.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/readwrite-splitting.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/readwrite-splitting.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/readwrite-splitting.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/shadow.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/shadow.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/shadow.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/shadow.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/sharding.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/sharding.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/sharding.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/config/sharding.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/entity/Order.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/entity/Order.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/entity/OrderItem.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/entity/OrderItem.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderItemRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderItemRepository.ftl
new file mode 100644
index 0000000..3e38a5b
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderItemRepository.ftl
@@ -0,0 +1,138 @@
+/*
+ * 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.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
+
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+public final class OrderItemRepository {
+    
+    private final DataSource dataSource;
+    
+    public OrderItemRepository(final DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+    
+    public void createTableIfNotExists() throws SQLException {
+        String sql = "CREATE TABLE IF NOT EXISTS t_order_item "
+            + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT 
NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY 
KEY (order_item_id))";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void dropTable() throws SQLException {
+        String sql = "DROP TABLE t_order_item";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void truncateTable() throws SQLException {
+        String sql = "TRUNCATE TABLE t_order_item";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+<#if feature=="shadow">
+    
+    public void createTableIfNotExistsShadow() throws SQLException {
+        String sql = "CREATE TABLE IF NOT EXISTS t_order_item "
+            + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT 
NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY 
KEY (order_item_id)) /*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void dropTableShadow() throws SQLException {
+        String sql = "DROP TABLE t_order_item /*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void truncateTableShadow() throws SQLException {
+        String sql = "TRUNCATE TABLE t_order_item /*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+</#if>
+    
+    public Long insert(final OrderItem orderItem) throws SQLException {
+        String sql = "INSERT INTO t_order_item (order_id, user_id, status) 
VALUES (?, ?, ?)";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+            preparedStatement.setLong(1, orderItem.getOrderId());
+            preparedStatement.setInt(2, orderItem.getUserId());
+            preparedStatement.setString(3, orderItem.getStatus());
+            preparedStatement.executeUpdate();
+            try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
+                if (resultSet.next()) {
+                    orderItem.setOrderItemId(resultSet.getLong(1));
+                }
+            }
+        }
+        return orderItem.getOrderItemId();
+    }
+    
+    public void delete(final Long orderItemId) throws SQLException {
+        String sql = "DELETE FROM t_order_item WHERE order_id=?";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql)) {
+            preparedStatement.setLong(1, orderItemId);
+            preparedStatement.executeUpdate();
+        }
+    }
+    
+    public List<OrderItem> selectAll() throws SQLException {
+        String sql = "SELECT i.* FROM t_order o, t_order_item i WHERE 
o.order_id = i.order_id";
+        return getOrderItems(sql);
+    }
+    
+    private List<OrderItem> getOrderItems(final String sql) throws 
SQLException {
+        List<OrderItem> result = new LinkedList<>();
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql);
+             ResultSet resultSet = preparedStatement.executeQuery()) {
+            while (resultSet.next()) {
+                OrderItem orderItem = new OrderItem();
+                orderItem.setOrderItemId(resultSet.getLong(1));
+                orderItem.setOrderId(resultSet.getLong(2));
+                orderItem.setUserId(resultSet.getInt(3));
+                orderItem.setStatus(resultSet.getString(4));
+                result.add(orderItem);
+            }
+        }
+        return result;
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderRepository.ftl
new file mode 100644
index 0000000..60e6815
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jdbc/OrderRepository.ftl
@@ -0,0 +1,142 @@
+/*
+ * 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.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
+
+import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+public final class OrderRepository {
+    
+    private final DataSource dataSource;
+    
+    public OrderRepository(final DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+    
+    public void createTableIfNotExists() throws SQLException {
+        String sql = "CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT 
NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id 
BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id))";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void dropTable() throws SQLException {
+        String sql = "DROP TABLE t_order";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public void truncateTable() throws SQLException {
+        String sql = "TRUNCATE TABLE t_order";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+<#if feature=="shadow">
+
+    public void createTableIfNotExistsShadow() throws SQLException {
+        String sql = "CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT 
NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id 
BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)) 
/*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+
+    public void dropTableShadow() throws SQLException {
+        String sql = "DROP TABLE t_order /*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+
+    public void truncateTableShadow() throws SQLException {
+        String sql = "TRUNCATE TABLE t_order /*shadow:true,foo:bar*/";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    public List<Order> selectShadowOrder() {
+        String sql = "SELECT * FROM t_order WHERE order_type=1";
+        return getOrders(sql);
+    }
+</#if>
+    
+    public Long insert(final Order order) throws SQLException {
+        String sql = "INSERT INTO t_order (user_id, order_type, address_id, 
status) VALUES (?, ?, ?, ?)";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+            preparedStatement.setInt(1, order.getUserId());
+            preparedStatement.setInt(2, order.getOrderType());
+            preparedStatement.setLong(3, order.getAddressId());
+            preparedStatement.setString(4, order.getStatus());
+            preparedStatement.executeUpdate();
+            try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
+                if (resultSet.next()) {
+                    order.setOrderId(resultSet.getLong(1));
+                }
+            }
+        }
+        return order;
+    }
+    
+    public void delete(final Long orderId) throws SQLException {
+        String sql = "DELETE FROM t_order WHERE order_id=?";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql)) {
+            preparedStatement.setLong(1, orderId);
+            preparedStatement.executeUpdate();
+        }
+    }
+    
+    public List<Order> selectAll() throws SQLException {
+        String sql = "SELECT * FROM t_order";
+        return getOrders(sql);
+    }
+    
+    private List<Order> getOrders(final String sql) throws SQLException {
+        List<Order> result = new LinkedList<>();
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = 
connection.prepareStatement(sql);
+             ResultSet resultSet = preparedStatement.executeQuery()) {
+            while (resultSet.next()) {
+                Order order = new Order();
+                order.setOrderId(resultSet.getLong(1));
+                order.setUserId(resultSet.getInt(2));
+                order.setAddressId(resultSet.getLong(3));
+                order.setStatus(resultSet.getString(4));
+                result.add(order);
+            }
+        }
+        return result;
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderItemRepository.ftl
similarity index 59%
copy from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
copy to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderItemRepository.ftl
index d1cb0db..9c093e5 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderItemRepository.ftl
@@ -15,14 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
 
-<#if feature=="encrypt" || feature=="shadow">
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-<#else>
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
 import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
-</#if>
 import org.springframework.stereotype.Repository;
 
 import javax.persistence.EntityManager;
@@ -31,25 +26,34 @@ import javax.persistence.Query;
 import javax.transaction.Transactional;
 import java.util.List;
 
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
 @Repository
 @Transactional
-public class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 {
+public class OrderItemRepository {
     
     @PersistenceContext
     private EntityManager entityManager;
-<#if feature=="encrypt">
-    <#include "userRepository.ftl">
-<#elseif feature=="shadow">
-    <#include "shadowJpaRepository.ftl">
-<#else>
-    <#include "orderRepository.ftl">
-</#if>
+    
+    public void createTableIfNotExists() throws SQLException {
+    }
+    
+    public void dropTable() throws SQLException {
+    }
+    
+    public void truncateTable() throws SQLException {
+    }
+    
+    public Long insert(final OrderItem orderItem) throws SQLException {
+        entityManager.persist(orderItem);
+        return orderItem.getOrderItemId();
+    }
+    
+    public void delete(final Long orderItemId) throws SQLException {
+        Query query = entityManager.createQuery("DELETE FROM OrderItem i WHERE 
i.orderId = ?1");
+        query.setParameter(1, orderId);
+        query.executeUpdate();
+    }
+    
+    public List<OrderItem> selectAll() throws SQLException {
+        return (List<OrderItem>) entityManager.createQuery("SELECT o from 
OrderItem o").getResultList();
+    }
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderRepository.ftl
similarity index 59%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderRepository.ftl
index d1cb0db..613a6e2 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/jpa/OrderRepository.ftl
@@ -15,14 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
 
-<#if feature=="encrypt" || feature=="shadow">
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-<#else>
 import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
-</#if>
 import org.springframework.stereotype.Repository;
 
 import javax.persistence.EntityManager;
@@ -31,25 +26,34 @@ import javax.persistence.Query;
 import javax.transaction.Transactional;
 import java.util.List;
 
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
 @Repository
 @Transactional
-public class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 {
+public class OrderRepository {
     
     @PersistenceContext
     private EntityManager entityManager;
-<#if feature=="encrypt">
-    <#include "userRepository.ftl">
-<#elseif feature=="shadow">
-    <#include "shadowJpaRepository.ftl">
-<#else>
-    <#include "orderRepository.ftl">
-</#if>
+
+    public void createTableIfNotExists() throws SQLException {
+    }
+    
+    public void dropTable() throws SQLException {
+    }
+    
+    public void truncateTable() throws SQLException {
+    }
+
+    public Long insert(final Order order) throws SQLException {
+        entityManager.persist(order);
+        return order.getOrderId();
+    }
+    
+    public void delete(final Long orderId) throws SQLException {
+        Query query = entityManager.createQuery("DELETE FROM Order o WHERE 
o.orderId = ?1");
+        query.setParameter(1, orderId);
+        query.executeUpdate();
+    }
+    
+    public List<Order> selectAll() throws SQLException {
+        return (List<Order>) entityManager.createQuery("SELECT o FROM Order 
o").getResultList();
+    }
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderItemRepository.ftl
similarity index 90%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderItemRepository.ftl
index 8214d32..cb90148 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderItemRepository.ftl
@@ -30,6 +30,14 @@ public interface OrderItemRepository {
     void truncateTable();
     
     void dropTable();
+
+<#if feature=="shadow">
+    void createTableIfNotExistsShadow();
+    
+    void truncateTableShadow();
+    
+    void dropTableShadow();
+</#if>
     
     void insert(OrderItem orderItem);
     
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderRepository.ftl
similarity index 85%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderRepository.ftl
index 213bee2..67a515d 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/java/repository/mybatis/OrderRepository.ftl
@@ -24,16 +24,26 @@ import java.util.List;
 
 @Mapper
 public interface OrderRepository {
-
+    
     void createTableIfNotExists();
-
+    
     void truncateTable();
-
+    
     void dropTable();
-
+    
+<#if feature=="shadow">
+    void createTableIfNotExistsShadow();
+    
+    void truncateTableShadow();
+    
+    void dropTableShadow();
+    
+    List<Order> selectShadowOrder();
+</#if>
+    
     void insert(Order order);
-
+    
     void delete(long orderId);
-
+    
     List<Order> selectAll();
 }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
deleted file mode 100644
index feed048..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')};
-
-<#if feature=="encrypt" || feature=="shadow">
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-<#else>
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
-</#if>
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
-    <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#assign featureName="">
-<#list feature?split("-") as feature1>
-    <#assign featureName=featureName + feature1?cap_first>
-</#list>
-@Service
-public final class 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
 {
-
-    @Resource
-    private 
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository
 repository;
-<#if feature=="encrypt">
-    <#include "userExampleService.ftl">
-<#elseif feature=="shadow">
-    <#include "shadowExampleService.ftl">
-<#else>
-    <#include "orderExampleService.ftl">
-</#if>
-}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderExampleService.ftl
deleted file mode 100644
index 388fbfd..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderExampleService.ftl
+++ /dev/null
@@ -1,66 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * Execute test.
-     */
-    public void run() {
-        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 = new Order();
-            order.setUserId(i);
-            order.setAddressId(i);
-            order.setStatus("INSERT_TEST");
-            repository.insertOrder(order);
-            OrderItem orderItem = new OrderItem();
-            orderItem.setOrderId(order.getOrderId());
-            orderItem.setUserId(i);
-            orderItem.setStatus("INSERT_TEST");
-            repository.insertOrderItem(orderItem);
-            result.add(order.getOrderId());
-        }
-        return result;
-    }
-    
-    private void deleteData(final List<Long> orderIds) {
-        System.out.println("---------------------------- Delete Data 
----------------------------");
-        for (Long each : orderIds) {
-            repository.deleteOrder(each);
-            repository.deleteOrderItem(each);
-        }
-    }
-    
-    private void printData() {
-        System.out.println("---------------------------- Print Order Data 
-----------------------");
-        for (Object each : repository.selectAllOrder()) {
-            System.out.println(each);
-        }
-        System.out.println("---------------------------- Print OrderItem Data 
-------------------");
-        for (Object each : repository.selectAllOrderItem()) {
-            System.out.println(each);
-        }
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderRepository.ftl
deleted file mode 100644
index 02c10bd..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/orderRepository.ftl
+++ /dev/null
@@ -1,46 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    public Long insertOrder(final Order order) {
-        entityManager.persist(order);
-        return order.getOrderId();
-    }
-
-    public Long insertOrderItem(final OrderItem orderItem) {
-        entityManager.persist(orderItem);
-        return orderItem.getOrderItemId();
-    }
-    
-    public List<Order> selectAllOrder() {
-        return (List<Order>) entityManager.createQuery("SELECT o FROM Order 
o").getResultList();
-    }
-    
-    public List<OrderItem> selectAllOrderItem() {
-        return (List<OrderItem>) entityManager.createQuery("SELECT o from 
OrderItem o").getResultList();
-    }
-
-    public void deleteOrder(final Long orderId) {
-        Query query = entityManager.createQuery("DELETE FROM Order o WHERE 
o.orderId = ?1");
-        query.setParameter(1, orderId);
-        query.executeUpdate();
-    }
-
-    public void deleteOrderItem(final Long orderId) {
-        Query query = entityManager.createQuery("DELETE FROM OrderItem i WHERE 
i.orderId = ?1");
-        query.setParameter(1, orderId);
-        query.executeUpdate();
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowExampleService.ftl
deleted file mode 100644
index e8f39c1..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowExampleService.ftl
+++ /dev/null
@@ -1,60 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * Execute test.
-     */
-    public void run() {
-        System.out.println("-------------- Process Success Begin 
---------------");
-        List<Integer> usersIds = insertData();
-        printData(); 
-        deleteData(usersIds);
-        printData();
-        System.out.println("-------------- Process Success Finish 
--------------");
-    }
-
-    private List<Integer> insertData() {
-        System.out.println("---------------------------- Insert Data 
----------------------------");
-        List<Integer> result = new ArrayList<>(10);
-        for (int i = 1; i <= 10; i++) {
-            User user = new User();
-            user.setUserName("test_" + i);
-            user.setPwd("pwd" + i);
-            user.setUserType(i % 2);
-            repository.insertUser(user);
-            result.add(user.getUserId());
-        }
-        return result;
-    }
-
-    private void deleteData(final List<Integer> userIds) {
-        System.out.println("---------------------------- Delete Data 
----------------------------");
-        for (Integer each : userIds) {
-            repository.deleteUser(each, 0);
-            repository.deleteUser(each, 1);
-        }
-    }
-    
-    private void printData() {
-        System.out.println("---------------------------- Print User Data 
-----------------------");
-        for (Object each : repository.selectUsers(0)) {
-            System.out.println(each);
-        }
-        for (Object each : repository.selectUsers(1)) {
-            System.out.println(each);
-        }
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowJpaRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowJpaRepository.ftl
deleted file mode 100644
index 0856944..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/shadowJpaRepository.ftl
+++ /dev/null
@@ -1,34 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    public int insertUser(final User user) {
-        entityManager.persist(user);
-        return user.getUserId();
-    }
-    
-    public List<User> selectUsers(final int userType) {
-        Query query = entityManager.createQuery("SELECT o FROM User o WHERE 
o.userType = ?1");
-        query.setParameter(1, userType);
-        return (List<User>) query.getResultList();
-    }
-
-    public void deleteUser(final int userId, final int userType) {
-        Query query = entityManager.createQuery("DELETE FROM User o WHERE 
o.userId = ?1 AND o.userType = ?2");
-        query.setParameter(1, userId);
-        query.setParameter(2, userType);
-        query.executeUpdate();
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userExampleService.ftl
deleted file mode 100644
index 538e988..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userExampleService.ftl
+++ /dev/null
@@ -1,55 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * Execute test.
-     */
-    public void run() {
-        System.out.println("-------------- Process Success Begin 
---------------");
-        List<Integer> usersIds = insertData();
-        printData(); 
-        deleteData(usersIds);
-        printData();
-        System.out.println("-------------- Process Success Finish 
--------------");
-    }
-
-    private List<Integer> insertData() {
-        System.out.println("---------------------------- Insert Data 
----------------------------");
-        List<Integer> result = new ArrayList<>(10);
-        for (int i = 1; i <= 10; i++) {
-            User user = new User();
-            user.setUsername("test_" + i);
-            user.setPwd("pwd" + i);
-            repository.insertUser(user);
-            result.add(user.getUserId());
-        }
-        return result;
-    }
-
-    private void deleteData(final List<Integer> userIds) {
-        System.out.println("---------------------------- Delete Data 
----------------------------");
-        for (Integer each : userIds) {
-            repository.deleteUser(each);
-        }
-    }
-    
-    private void printData() {
-        System.out.println("---------------------------- Print User Data 
-----------------------");
-        for (Object each : repository.selectAllUsers()) {
-            System.out.println(each);
-        }
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userRepository.ftl
deleted file mode 100644
index 93010f8..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/userRepository.ftl
+++ /dev/null
@@ -1,32 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    public int insertUser(final User user) {
-        entityManager.persist(user);
-        return user.getUserId();
-    }
-    
-    public List<User> selectAllUsers() {
-        return (List<User>) entityManager.createQuery("SELECT o FROM User 
o").getResultList();
-    }
-
-    public void deleteUser(final int userId) {
-        Query query = entityManager.createQuery("DELETE FROM User o WHERE 
o.userId = ?1");
-        query.setParameter(1, userId);
-        query.executeUpdate();
-    }
-}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/UserRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/UserRepository.ftl
deleted file mode 100644
index 15a89aa..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/UserRepository.ftl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
-
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-
-import java.util.List;
-
-@Mapper
-public interface UserRepository {
-    
-    void createTableIfNotExists();
-    
-    void truncateTable();
-    
-    void dropTable();
-    
-    void insert(User user);
-    
-    void delete(long userId);
-    
-    List<User> selectAll();
-}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/UserMapper.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/UserMapper.ftl
deleted file mode 100644
index 9af2d93..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/UserMapper.ftl
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
-<mapper namespace="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.UserRepository">
-    <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User">
-        <result column="user_id" property="userId" jdbcType="INTEGER"/>
-        <result column="username" property="username" jdbcType="VARCHAR"/>
-        <result column="pwd" property="pwd" jdbcType="VARCHAR"/>
-        <result column="assisted_query_pwd" property="assistedQueryPwd" 
jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <update id="createTableIfNotExists">
-        CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL 
AUTO_INCREMENT, username VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY (user_id));
-    </update>
-
-    <update id="truncateTable">
-        TRUNCATE TABLE t_user;
-    </update>
-
-    <update id="dropTable">
-        DROP TABLE IF EXISTS t_user;
-    </update>
-
-    <insert id="insert">
-        INSERT INTO t_user (user_id, username, pwd) VALUES 
(${r"#{userId,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, 
#{pwd,jdbcType=VARCHAR}"})
-    </insert>
-
-    <delete id="delete">
-        DELETE FROM t_user WHERE user_id = ${r"#{userId,jdbcType=INTEGER}"};
-    </delete>
-
-    <select id="selectAll" resultMap="baseResultMap">
-        SELECT * FROM t_user;
-    </select>
-</mapper>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/shadowUserMapper.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/shadowUserMapper.ftl
deleted file mode 100644
index 3532b19..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/shadowUserMapper.ftl
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
-<mapper namespace="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.UserRepository">
-    <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User">
-        <result column="user_id" property="userId" jdbcType="INTEGER"/>
-        <result column="user_type" property="userType" jdbcType="INTEGER"/>
-        <result column="username" property="username" jdbcType="VARCHAR"/>
-        <result column="pwd" property="pwd" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <update id="createTableIfNotExistsNative">
-        CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL 
AUTO_INCREMENT, user_type INT(11), username VARCHAR(200), pwd VARCHAR(200), 
PRIMARY KEY (user_id));
-    </update>
-
-    <update id="createTableIfNotExistsShadow">
-        CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL 
AUTO_INCREMENT, user_type INT(11), username VARCHAR(200), pwd VARCHAR(200), 
PRIMARY KEY (user_id)) /*shadow:true,foo:bar*/;
-    </update>
-
-    <update id="truncateTableNative">
-        TRUNCATE TABLE t_user;
-    </update>
-
-    <update id="truncateTableShadow">
-        TRUNCATE TABLE t_user /*shadow:true,foo:bar*/;
-    </update>
-
-    <update id="dropTableNative">
-        DROP TABLE IF EXISTS t_user;
-    </update>
-
-    <update id="dropTableShadow">
-        DROP TABLE IF EXISTS t_user /*shadow:true,foo:bar*/;
-    </update>
-
-    <insert id="insert">
-        INSERT INTO t_user (user_id, user_type, username, pwd) VALUES 
(${r"#{userId,jdbcType=INTEGER}, #{userType,jdbcType=INTEGER}, 
#{username,jdbcType=VARCHAR}, #{pwd,jdbcType=VARCHAR}"})
-    </insert>
-
-    <delete id="deleteByUserIdAndUserType">
-        DELETE FROM t_user WHERE user_id = ${r"#{userId,jdbcType=INTEGER}"} 
AND user_type = ${r"#{userType,jdbcType=INTEGER}"};
-    </delete>
-
-    <select id="selectAll" resultMap="baseResultMap">
-        SELECT * FROM t_user WHERE user_type = 
${r"#{userType,jdbcType=INTEGER}"};
-    </select>
-
-    <select id="selectAllByUserType" resultMap="baseResultMap">
-        SELECT * FROM t_user WHERE user_type = 
${r"#{userType,jdbcType=INTEGER}"};
-    </select>
-</mapper>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/shadowUserRepository.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/shadowUserRepository.ftl
deleted file mode 100644
index a4d6980..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/shadowUserRepository.ftl
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository;
-
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.User;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Mapper
-public interface UserRepository {
-    
-    default void createTableIfNotExists() {
-        createTableIfNotExistsNative();
-        createTableIfNotExistsShadow();
-    }
-
-    void createTableIfNotExistsNative();
-
-    void createTableIfNotExistsShadow();
-    
-    default void truncateTable() {
-        truncateTableShadow();
-        truncateTableNative();
-    }
-
-    void truncateTableNative();
-
-    void truncateTableShadow();
-    
-    default void dropTable() {
-        dropTableShadow();
-        dropTableNative();
-    }
-    
-    void insert(User user);
-
-    void dropTableNative();
-
-    void dropTableShadow();
-    
-    default List<User> selectAll() {
-        List<User> result = new ArrayList<>();
-        result.addAll(selectAllByUserType(0));
-        result.addAll(selectAllByUserType(1));
-        return result;
-    }
-
-    List<User> selectAllByUserType(int userType);
-    
-    default void delete(Long userId) {
-        deleteByUserIdAndUserType(userId, (int) (userId % 2));
-    }
-
-    void deleteByUserIdAndUserType(@Param("userId") Long userId, 
@Param("userType") int userType);
-}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/orderExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/orderExampleService.ftl
deleted file mode 100644
index 64db8bd..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/orderExampleService.ftl
+++ /dev/null
@@ -1,93 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * 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-example-engine/src/main/resources/template/log/logback.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/logback.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/log/logback.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/logback.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderItemMapper.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderItemMapper.ftl
similarity index 71%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderItemMapper.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderItemMapper.ftl
index b690971..e9969a6 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderItemMapper.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderItemMapper.ftl
@@ -22,11 +22,12 @@
         <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"/>
+        <result column="phone" property="phone" jdbcType="VARCHAR"/>
         <result column="status" property="status" jdbcType="VARCHAR"/>
     </resultMap>
     
     <update id="createTableIfNotExists">
-        CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT 
AUTO_INCREMENT, order_id BIGINT, user_id INT NOT NULL, status VARCHAR(50) , 
PRIMARY KEY (order_item_id));
+        CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT 
AUTO_INCREMENT, order_id BIGINT, user_id INT NOT NULL, phone VARCHAR(50), 
status VARCHAR(50) , PRIMARY KEY (order_item_id));
     </update>
     
     <update id="truncateTable">
@@ -36,9 +37,23 @@
     <update id="dropTable">
         DROP TABLE IF EXISTS t_order_item;
     </update>
+ <#if feature=="shadow">
+    
+    <update id="createTableIfNotExistsShadow">
+        CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT 
AUTO_INCREMENT, order_id BIGINT, user_id INT NOT NULL, phone VARCHAR(50), 
status VARCHAR(50) , PRIMARY KEY (order_item_id));
+    </update>
+    
+    <update id="truncateTableShadow">
+        TRUNCATE TABLE t_order_item;
+    </update>
+    
+    <update id="dropTableShadow">
+        DROP TABLE IF EXISTS t_order_item;
+    </update>
+ </#if>
     
     <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, phone, status) VALUES 
(${r"#{orderId,jdbcType=INTEGER}"}, ${r"#{userId,jdbcType=INTEGER}"}, 
${r"#{phone,jdbcType=VARCHAR}"}, ${r"#{status,jdbcType=VARCHAR}"});
     </insert>
     
     <delete id="delete">
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderMapper.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderMapper.ftl
similarity index 69%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderMapper.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderMapper.ftl
index 5bad8c1..1f7da2a 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/mappers/OrderMapper.ftl
+++ 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/mappers/OrderMapper.ftl
@@ -20,13 +20,14 @@
 <mapper namespace="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.repository.OrderRepository">
     <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.${feature?replace('-', 
'.')}.${framework?replace('-', '.')}.entity.Order">
         <result column="order_id" property="orderId" jdbcType="BIGINT"/>
+        <result column="order_type" property="orderType" jdbcType="BIGINT"/>
         <result column="user_id" property="userId" jdbcType="INTEGER"/>
         <result column="address_id" property="addressId" jdbcType="BIGINT"/>
         <result column="status" property="status" jdbcType="VARCHAR"/>
     </resultMap>
 
     <update id="createTableIfNotExists">
-        CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, 
user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY 
KEY (order_id));
+        CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, 
order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status 
VARCHAR(50), PRIMARY KEY (order_id));
     </update>
     
     <update id="truncateTable">
@@ -36,9 +37,23 @@
     <update id="dropTable">
         DROP TABLE IF EXISTS t_order;
     </update>
+ <#if feature=="shadow">
+    
+    <update id="createTableIfNotExistsShadow">
+        CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, 
order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status 
VARCHAR(50), PRIMARY KEY (order_id)); /*shadow:true,foo:bar*/
+    </update>
+    
+    <update id="truncateTableShadow">
+        TRUNCATE TABLE t_order; /*shadow:true,foo:bar*/
+    </update>
+    
+    <update id="dropTableShadow">
+        DROP TABLE IF EXISTS t_order; /*shadow:true,foo:bar*/
+    </update>
+ </#if>
     
     <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, order_type, address_id, status) VALUES 
(${r"#{userId,jdbcType=INTEGER}"}, ${r"#{orderType,jdbcType=INTEGER}"}, 
${r"#{addressId,jdbcType=BIGINT}"}, ${r"#{status,jdbcType=VARCHAR}"});
     </insert>
     
     <delete id="delete">
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/application.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/application.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/db-discovery.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/db-discovery.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/db-discovery.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/db-discovery.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/encrypt.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/encrypt.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/encrypt.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/encrypt.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/readwrite-splitting.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/readwrite-splitting.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/readwrite-splitting.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/readwrite-splitting.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shadow.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/shadow.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shadow.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/shadow.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/sharding.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/sharding.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/sharding.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/properties/sharding.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spi/encryptAlgorithm.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/spi/encryptAlgorithm.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/spi/encryptAlgorithm.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/spi/encryptAlgorithm.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/application.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/application.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/db-discovery.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/db-discovery.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/db-discovery.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/db-discovery.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/encrypt.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/encrypt.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/encrypt.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/encrypt.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwrite-splitting.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/readwrite-splitting.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwrite-splitting.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/readwrite-splitting.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/shadow.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/shadow.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/shadow.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/shadow.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/sharding.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/sharding.ftl
similarity index 100%
rename from 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/sharding.ftl
rename to 
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/resources/xml/sharding.ftl
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/shadowUserExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/shadowUserExampleService.ftl
deleted file mode 100644
index bedeae5..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/shadowUserExampleService.ftl
+++ /dev/null
@@ -1,71 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * Initialize the database test environment.
-     * @throws SQLException
-     */
-    private void initEnvironment() {
-        userRepository.createTableIfNotExists();
-        userRepository.truncateTable();
-    }
-    
-    private void processSuccess() {
-        System.out.println("-------------- Process Success Begin 
---------------");
-        List<Long> orderIds = insertData();
-        printData(); 
-        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++) {
-            User user = new User();
-            user.setUserId(i);
-            user.setUserType(i % 2);
-            user.setUserName("test_" + i);
-            user.setPwd("pwd" + i);
-            userRepository.insert(user);
-            result.add((long) user.getUserId());
-        }
-        return result;
-    }
-
-    private void deleteData(final List<Long> orderIds) {
-        System.out.println("---------------------------- Delete Data 
----------------------------");
-        for (Long each : orderIds) {
-            userRepository.delete(each);
-        }
-    }
-    
-    private void printData() {
-        System.out.println("---------------------------- Print Order Data 
-----------------------");
-        for (User each : userRepository.selectAll()) {
-            System.out.println(each);
-        }
-    }
-    
-    /**
-     * Restore the environment.
-     * @throws SQLException
-     */
-    private void cleanEnvironment() {
-        userRepository.dropTable();
-    }
diff --git 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/userExampleService.ftl
 
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/userExampleService.ftl
deleted file mode 100644
index 90c64b4..0000000
--- 
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/userExampleService.ftl
+++ /dev/null
@@ -1,71 +0,0 @@
-<#--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-    
-    /**
-     * Initialize the database test environment.
-     * @throws SQLException
-     */
-    private void initEnvironment() {
-        userRepository.createTableIfNotExists();
-        userRepository.truncateTable();
-    }
-    
-    private void processSuccess() {
-        System.out.println("-------------- Process Success Begin 
---------------");
-        List<Long> orderIds = insertData();
-        printData(); 
-        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++) {
-            User user = new User();
-            user.setUserId(i);
-            user.setUserName("test_mybatis_" + i);
-            user.setPwd("pwd_mybatis_" + i);
-            userRepository.insert(user);
-            result.add((long) user.getUserId());
-        }
-        return result;
-    }
-
-    private void deleteData(final List<Long> orderIds) {
-        System.out.println("---------------------------- Delete Data 
----------------------------");
-        for (Long each : orderIds) {
-            userRepository.delete(each);
-        }
-    }
-    
-    private void printData() {
-        System.out.println("---------------------------- Print Order Data 
-----------------------");
-        for (Object each : userRepository.selectAll()) {
-            System.out.println(each);
-        }
-    }
-    
-    /**
-     * Restore the environment.
-     * @throws SQLException
-     */
-    private void cleanEnvironment() {
-        userRepository.dropTable();
-    }
-

Reply via email to