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 d0439ce Add encrypt example and adjust template (#13923)
d0439ce is described below
commit d0439ce160568d32a4d45eb3499b26b74991581f
Author: Guocheng Tang <[email protected]>
AuthorDate: Fri Dec 3 20:59:39 2021 +0800
Add encrypt example and adjust template (#13923)
* Add encrypt example and adjust template
* Add new line
---
.../engine/SpringbootStarterJDBCGenerator.java | 6 +-
.../engine/SpringbootStarterJpaGenerator.java | 5 +
.../engine/SpringbootStarterMybatisGenerator.java | 8 +-
.../springboot-starter-jdbc/data-model.yaml | 2 +-
.../springboot-starter-jpa/data-model.yaml | 2 +-
.../springboot-starter-mybatis/data-model.yaml | 2 +-
.../src/main/resources/template/ExampleService.ftl | 4 +-
.../src/main/resources/template/entity/User.ftl | 27 +++-
.../resources/template/properties/application.ftl | 9 ++
.../template/properties/encryptApplication.ftl | 25 ++++
.../pom.xml | 3 +
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 2 +-
.../pom.xml | 28 ++--
...ryLocalEncryptSpringbootStarterJdbcExample.java | 34 +++++
...EncryptSpringbootStarterJdbcExampleService.java | 153 +++++++++++++++++++++
.../TestQueryAssistedShardingEncryptAlgorithm.java | 55 ++++++++
.../springboot/starter/jdbc/entity/User.java} | 2 +-
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 2 +-
.../src/main/resources/application.properties} | 27 ++--
.../src/main/resources/logback.xml | 34 +++++
.../pom.xml | 68 +++++++++
...oryLocalEncryptSpringbootStarterJpaExample.java | 36 +++++
...lEncryptSpringbootStarterJpaExampleService.java | 71 ++++++++++
...LocalEncryptSpringbootStarterJpaRepository.java | 50 +++++++
.../TestQueryAssistedShardingEncryptAlgorithm.java | 55 ++++++++
.../springboot/starter/jpa/entity/User.java} | 19 ++-
...he.shardingsphere.encrypt.spi.EncryptAlgorithm} | 6 +-
.../src/main/resources/application.properties} | 26 ++--
.../src/main/resources/logback.xml | 34 +++++
.../pom.xml | 22 +--
...ocalEncryptSpringbootStarterMybatisExample.java | 36 +++++
...ryptSpringbootStarterMybatisExampleService.java | 103 ++++++++++++++
.../TestQueryAssistedShardingEncryptAlgorithm.java | 55 ++++++++
.../springboot/starter/mybatis/entity/User.java} | 6 +-
.../starter/mybatis/repository/UserRepository.java | 39 ++++++
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 2 +-
.../src/main/resources/application.properties} | 22 ++-
.../src/main/resources/logback.xml | 34 +++++
.../src/main/resources/mappers/UserMapper.xml | 51 +++++++
39 files changed, 1084 insertions(+), 81 deletions(-)
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
index 3aa7da3..2f60a3e 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
@@ -35,7 +35,11 @@ public final class SpringbootStarterJDBCGenerator extends
ExampleGenerateEngine
UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
-
+ UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
+ UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm",
"TestQueryAssistedShardingEncryptAlgorithm.java");
+
+ RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
+ RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm",
"META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
RESOURCE_TEMPLATE_MAP.put("properties/application",
"application.properties");
}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
index 28a2ab1..293548b 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
@@ -36,6 +36,11 @@ public final class SpringbootStarterJpaGenerator extends
ExampleGenerateEngine {
UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
+ UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
+ UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm",
"TestQueryAssistedShardingEncryptAlgorithm.java");
+
+ RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
+ RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm",
"META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
RESOURCE_TEMPLATE_MAP.put("properties/application",
"application.properties");
}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
index acb7955..e141bfd 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
@@ -37,9 +37,15 @@ public final class SpringbootStarterMybatisGenerator extends
ExampleGenerateEngi
UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
UN_NAME_TEMPLATE_MAP.put("mybatis/OrderItemRepository",
"repository/OrderItemRepository.java");
UN_NAME_TEMPLATE_MAP.put("mybatis/OrderRepository",
"repository/OrderRepository.java");
+ UN_NAME_TEMPLATE_MAP.put("mybatis/UserRepository",
"repository/UserRepository.java");
+ UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
+ UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm",
"TestQueryAssistedShardingEncryptAlgorithm.java");
+ RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
+ RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm",
"META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper",
"mappers/OrderItemMapper.xml");
- RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper",
"mappers/OrderItemMapper.xml");
+ RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper",
"mappers/OrderMapper.xml");
+ RESOURCE_TEMPLATE_MAP.put("mappers/UserMapper",
"mappers/UserMapper.xml");
RESOURCE_TEMPLATE_MAP.put("properties/application",
"application.properties");
}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
index 3083fa6..9a18157 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: readwrite-splitting
+feature: encrypt
framework: springboot-starter-jdbc
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
index a090d11..72d371a 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: readwrite-splitting
+feature: encrypt
framework: springboot-starter-jpa
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
index 1485b0f..6df8949 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: readwrite-splitting
+feature: encrypt
framework: springboot-starter-mybatis
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
index 9ebeed7..04373ed 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')};
<#if feature=="encrypt">
-import
org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.entity.User;
-import
org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.repository.UserRepository;
+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;
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
index f7e0660..7186062 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
@@ -17,16 +17,39 @@
package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
+<#if framework?contains("jpa")>
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+</#if>
import java.io.Serializable;
+<#if framework?contains("jpa")>
+@Entity
+@Table(name = "t_user")
+</#if>
public class User implements Serializable {
private static final long serialVersionUID = 263434701950670170L;
+ <#if framework?contains("jpa")>
+ @Id
+ @Column(name = "user_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ </#if>
private int userId;
-
+
+ <#if framework?contains("jpa")>
+ @Column(name = "user_name")
+ </#if>
private String userName;
-
+
+ <#if framework?contains("jpa")>
+ @Column(name = "pwd")
+ </#if>
private String pwd;
public int getUserId() {
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/properties/application.ftl
index 27f3f3d..dfff3a1 100644
---
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/properties/application.ftl
@@ -18,6 +18,11 @@
<#if framework?contains("mybatis")>
mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
+<#elseif framework?contains("jpa")>
+spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
+spring.jpa.properties.hibernate.show_sql=false
+
</#if>
spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
@@ -43,4 +48,8 @@ spring.shardingsphere.datasource.names=ds-0,ds-1
spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
<#include "readwriteSplittingApplication.ftl">
+<#elseif feature=="encrypt">
+spring.shardingsphere.datasource.names=ds-0
+
+ <#include "encryptApplication.ftl">
</#if>
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/encryptApplication.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/encryptApplication.ftl
new file mode 100644
index 0000000..5a10026
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/encryptApplication.ftl
@@ -0,0 +1,25 @@
+<#--
+ ~ 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.
+ -->
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=assistedTest
+
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.assisted-query-column=assisted_query_pwd
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
index 4038757..a20f71e 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
@@ -34,5 +34,8 @@
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jdbc-example</module>
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jpa-example</module>
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example</module>
+
<module>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example</module>
+
<module>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example</module>
+
<module>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example</module>
</modules>
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-exa
[...]
index 2d0feb8..038474f 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.TestQueryAssistedShardingEncryptAlgorithm
\ No newline at end of file
+org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.TestQueryAssistedShardingEncryptAlgorithm
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/pom.xml
similarity index 61%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/pom.xml
index 4038757..fafa8c4 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/pom.xml
@@ -20,19 +20,29 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-example</artifactId>
<groupId>org.apache.shardingsphere.example</groupId>
<version>5.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-encrypt-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-jdbc-memory-local-encrypt-jdbc-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jdbc-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jpa-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot</artifactId>
+ <version>2.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ <version>2.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ </dependency>
+ </dependencies>
+
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/MemoryLocalEncryptSpringbootStarterJdbcExample.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-examp
[...]
new file mode 100644
index 0000000..9bf11fa
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/MemoryLocalEncryptSpringbootStarterJdbcExample.java
@@ -0,0 +1,34 @@
+/*
+ * 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.encrypt.springboot.starter.jdbc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@SpringBootApplication
+public class MemoryLocalEncryptSpringbootStarterJdbcExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(MemoryLocalEncryptSpringbootStarterJdbcExample.class,
args)) {
+ MemoryLocalEncryptSpringbootStarterJdbcExampleService
exampleService =
applicationContext.getBean(MemoryLocalEncryptSpringbootStarterJdbcExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/MemoryLocalEncryptSpringbootStarterJdbcExampleService.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memor
[...]
new file mode 100644
index 0000000..525a5df
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/MemoryLocalEncryptSpringbootStarterJdbcExampleService.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.encrypt.springboot.starter.jdbc;
+
+import lombok.AllArgsConstructor;
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.jdbc.entity.User;
+import org.springframework.stereotype.Service;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public final class MemoryLocalEncryptSpringbootStarterJdbcExampleService {
+
+ private final DataSource dataSource;
+
+ /**
+ * Execute test.
+ *
+ * @throws SQLException
+ */
+ public void run() throws SQLException {
+ try {
+ this.initEnvironment();
+ this.processSuccess();
+ } finally {
+ this.cleanEnvironment();
+ }
+ }
+
+
+ /**
+ * Initialize the database test environment.
+ * @throws SQLException
+ */
+ private void initEnvironment() throws SQLException {
+ String createUserTableSql = "CREATE TABLE IF NOT EXISTS t_user"
+ + "(user_id INT NOT NULL AUTO_INCREMENT, user_name
VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY (user_id))";
+ String truncateUserTable = "TRUNCATE TABLE t_user";
+
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(createUserTableSql);
+ statement.executeUpdate(truncateUserTable);
+ }
+ }
+
+ private void processSuccess() throws SQLException {
+ System.out.println("-------------- Process Success Begin
---------------");
+ List<Long> ids = insertData();
+ printData();
+ deleteData(ids);
+ printData();
+ System.out.println("-------------- Process Success Finish
--------------");
+ }
+
+ private List<Long> insertData() throws SQLException {
+ System.out.println("---------------------------- Insert Data
----------------------------");
+ List<Long> result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ User user = new User();
+ user.setUserId(i);
+ user.setUserName("test_" + i);
+ user.setPwd("pwd" + i);
+ insert(user);
+ result.add((long) user.getUserId());
+ }
+ return result;
+ }
+
+ private long insert(final User user) throws SQLException {
+ String sql = "INSERT INTO t_user (user_id, user_name, pwd) VALUES (?,
?, ?)";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement =
connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, user.getUserId());
+ preparedStatement.setString(2, user.getUserName());
+ preparedStatement.setString(3, user.getPwd());
+ preparedStatement.executeUpdate();
+ }
+ return user.getUserId();
+ }
+
+ private void deleteData(final List<Long> orderIds) throws SQLException {
+ System.out.println("---------------------------- Delete Data
----------------------------");
+ String sql = "DELETE FROM t_user WHERE user_id=?";
+ for (Long each : orderIds) {
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement =
connection.prepareStatement(sql)) {
+ preparedStatement.setLong(1, each);
+ preparedStatement.executeUpdate();
+ }
+ }
+ }
+
+ private void printData() throws SQLException {
+ System.out.println("---------------------------- Print User Data
-----------------------");
+ for (Object each : this.getUsers()) {
+ System.out.println(each);
+ }
+ }
+
+ protected List<User> getUsers() throws SQLException {
+ List<User> result = new LinkedList<>();
+ String sql = "SELECT * FROM t_user";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement =
connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ User user = new User();
+ user.setUserId(resultSet.getInt("user_id"));
+ user.setUserName(resultSet.getString("user_name"));
+ user.setPwd(resultSet.getString("pwd"));
+ result.add(user);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Restore the environment.
+ * @throws SQLException
+ */
+ private void cleanEnvironment() throws SQLException {
+ String dropUserSql = "DROP TABLE t_user";
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(dropUserSql);
+ }
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/TestQueryAssistedShardingEncryptAlgorithm.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/sh
[...]
new file mode 100644
index 0000000..1c05a84
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/TestQueryAssistedShardingEncryptAlgorithm.java
@@ -0,0 +1,55 @@
+/*
+ * 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.encrypt.springboot.starter.jdbc;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
+
+import java.util.Properties;
+
+public final class TestQueryAssistedShardingEncryptAlgorithm implements
QueryAssistedEncryptAlgorithm<Object, String> {
+
+ @Getter
+ @Setter
+ private Properties props;
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public String encrypt(final Object plainValue) {
+ return "encryptValue";
+ }
+
+ @Override
+ public Object decrypt(final String cipherValue) {
+ return "decryptValue";
+ }
+
+ @Override
+ public String queryAssistedEncrypt(final Object plainValue) {
+ return "assistedEncryptValue";
+ }
+
+ @Override
+ public String getType() {
+ return "assistedTest";
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/entity/User.java
similarity index 93%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/entity/User.java
index f7e0660..ff9a6f3 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jdbc/entity/User.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
+package
org.apache.shardingsphere.example.encrypt.springboot.starter.jdbc.entity;
import java.io.Serializable;
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-exa
[...]
similarity index 87%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index 2d0feb8..3638c25 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.TestQueryAssistedShardingEncryptAlgorithm
\ No newline at end of file
+org.apache.shardingsphere.example.encrypt.springboot.starter.jdbc.TestQueryAssistedShardingEncryptAlgorithm
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/application.properties
similarity index 64%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/application.properties
index 27f3f3d..8853de0 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/application.properties
@@ -15,10 +15,6 @@
# limitations under the License.
#
-<#if framework?contains("mybatis")>
-mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
-
-</#if>
spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
@@ -33,14 +29,17 @@ spring.shardingsphere.datasource.ds-1.username=root
spring.shardingsphere.datasource.ds-1.password=root
spring.shardingsphere.datasource.ds-1.max-active=16
-<#if feature=="sharding">
-spring.shardingsphere.schema.name=sharding
-
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
- <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
+spring.shardingsphere.datasource.names=ds-0
+
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=assistedTest
- <#include "readwriteSplittingApplication.ftl">
-</#if>
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.logic-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.logic-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.assisted-query-column=assisted_query_pwd
+
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/logback.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/sharding
[...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jdbc-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger]
%msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local
[...]
new file mode 100644
index 0000000..20a029b
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/pom.xml
@@ -0,0 +1,68 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-example</artifactId>
+ <groupId>org.apache.shardingsphere.example</groupId>
+ <version>5.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example</artifactId>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ <version>2.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot</artifactId>
+ <version>2.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>5.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaExample.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/
[...]
new file mode 100644
index 0000000..3c4658d
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaExample.java
@@ -0,0 +1,36 @@
+/*
+ * 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.encrypt.springboot.starter.jpa;
+
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@EntityScan(basePackages =
"org.apache.shardingsphere.example.encrypt.springboot.starter.jpa.entity")
+@SpringBootApplication
+public class MemoryLocalEncryptSpringbootStarterJpaExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(MemoryLocalEncryptSpringbootStarterJpaExample.class,
args)) {
+ MemoryLocalEncryptSpringbootStarterJpaExampleService
exampleService =
applicationContext.getBean(MemoryLocalEncryptSpringbootStarterJpaExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaExampleService.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-e
[...]
new file mode 100644
index 0000000..7cebf5e
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaExampleService.java
@@ -0,0 +1,71 @@
+/*
+ * 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.encrypt.springboot.starter.jpa;
+
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.jpa.entity.User;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalEncryptSpringbootStarterJpaExampleService {
+
+ @Resource
+ private MemoryLocalEncryptSpringbootStarterJpaRepository repository;
+
+ /**
+ * 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-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaRepository.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-examp
[...]
new file mode 100644
index 0000000..c477407
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/MemoryLocalEncryptSpringbootStarterJpaRepository.java
@@ -0,0 +1,50 @@
+/*
+ * 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.encrypt.springboot.starter.jpa;
+
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.jpa.entity.User;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import javax.transaction.Transactional;
+import java.util.List;
+
+@Repository
+@Transactional
+public class MemoryLocalEncryptSpringbootStarterJpaRepository {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ 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-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/TestQueryAssistedShardingEncryptAlgorithm.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shar
[...]
new file mode 100644
index 0000000..eaef43f
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/TestQueryAssistedShardingEncryptAlgorithm.java
@@ -0,0 +1,55 @@
+/*
+ * 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.encrypt.springboot.starter.jpa;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
+
+import java.util.Properties;
+
+public final class TestQueryAssistedShardingEncryptAlgorithm implements
QueryAssistedEncryptAlgorithm<Object, String> {
+
+ @Getter
+ @Setter
+ private Properties props;
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public String encrypt(final Object plainValue) {
+ return "encryptValue";
+ }
+
+ @Override
+ public Object decrypt(final String cipherValue) {
+ return "decryptValue";
+ }
+
+ @Override
+ public String queryAssistedEncrypt(final Object plainValue) {
+ return "assistedEncryptValue";
+ }
+
+ @Override
+ public String getType() {
+ return "assistedTest";
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/entity/User.java
similarity index 77%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/entity/User.java
index f7e0660..a67e443 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/jpa/entity/User.java
@@ -15,18 +15,31 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
+package
org.apache.shardingsphere.example.encrypt.springboot.starter.jpa.entity;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
import java.io.Serializable;
+@Entity
+@Table(name = "t_user")
public class User implements Serializable {
private static final long serialVersionUID = 263434701950670170L;
+ @Id
+ @Column(name = "user_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private int userId;
-
+
+ @Column(name = "user_name")
private String userName;
-
+
+ @Column(name = "pwd")
private String pwd;
public int getUserId() {
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
similarity index 88%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index a090d11..3603147 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -15,8 +15,4 @@
# limitations under the License.
#
-mode: memory
-transaction: local
-feature: readwrite-splitting
-framework: springboot-starter-jpa
-
+org.apache.shardingsphere.example.encrypt.springboot.starter.jpa.TestQueryAssistedShardingEncryptAlgorithm
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/application.properties
similarity index 64%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/application.properties
index 27f3f3d..d19a73c 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/application.properties
@@ -15,10 +15,10 @@
# limitations under the License.
#
-<#if framework?contains("mybatis")>
-mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
+spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
+spring.jpa.properties.hibernate.show_sql=false
-</#if>
spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
@@ -33,14 +33,14 @@ spring.shardingsphere.datasource.ds-1.username=root
spring.shardingsphere.datasource.ds-1.password=root
spring.shardingsphere.datasource.ds-1.max-active=16
-<#if feature=="sharding">
-spring.shardingsphere.schema.name=sharding
+spring.shardingsphere.datasource.names=ds-0
+
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=assistedTest
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
- <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
-
- <#include "readwriteSplittingApplication.ftl">
-</#if>
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.assisted-query-column=assisted_query_pwd
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/logback.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardings
[...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-jpa-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger]
%msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/pom.xml
similarity index 69%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/pom.xml
index 4038757..1140d3b 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/pom.xml
@@ -20,19 +20,23 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-example</artifactId>
<groupId>org.apache.shardingsphere.example</groupId>
<version>5.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-encrypt-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-jdbc-memory-local-encrypt-jdbc-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jdbc-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-jpa-example</module>
-
<module>shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mybatis.spring.boot</groupId>
+ <artifactId>mybatis-spring-boot-starter</artifactId>
+ </dependency>
+ </dependencies>
+
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/MemoryLocalEncryptSpringbootStarterMybatisExample.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-mem
[...]
new file mode 100644
index 0000000..f16f919
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/MemoryLocalEncryptSpringbootStarterMybatisExample.java
@@ -0,0 +1,36 @@
+/*
+ * 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.encrypt.springboot.starter.mybatis;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@MapperScan("org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.repository")
+@SpringBootApplication
+public class MemoryLocalEncryptSpringbootStarterMybatisExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(MemoryLocalEncryptSpringbootStarterMybatisExample.class,
args)) {
+ MemoryLocalEncryptSpringbootStarterMybatisExampleService
exampleService =
applicationContext.getBean(MemoryLocalEncryptSpringbootStarterMybatisExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/MemoryLocalEncryptSpringbootStarterMybatisExampleService.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-j
[...]
new file mode 100644
index 0000000..588459a
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/MemoryLocalEncryptSpringbootStarterMybatisExampleService.java
@@ -0,0 +1,103 @@
+/*
+ * 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.encrypt.springboot.starter.mybatis;
+
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.entity.User;
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.repository.UserRepository;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalEncryptSpringbootStarterMybatisExampleService {
+
+ @Resource
+ private UserRepository userRepository;
+
+ /**
+ * Execute test.
+ *
+ * @throws SQLException
+ */
+ public void run() {
+ try {
+ this.initEnvironment();
+ this.processSuccess();
+ } finally {
+ this.cleanEnvironment();
+ }
+ }
+
+ /**
+ * Initialize the database test environment.
+ * @throws SQLException
+ */
+ private void initEnvironment() {
+ userRepository.createTableIfNotExists();
+ userRepository.truncateTable();
+ }
+
+ private void processSuccess() {
+ System.out.println("-------------- Process Success Begin
---------------");
+ List<Long> orderIds = insertData();
+ printData();
+ 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();
+ }
+
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/TestQueryAssistedShardingEncryptAlgorithm.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-exam
[...]
new file mode 100644
index 0000000..eedc0c4
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/TestQueryAssistedShardingEncryptAlgorithm.java
@@ -0,0 +1,55 @@
+/*
+ * 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.encrypt.springboot.starter.mybatis;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
+
+import java.util.Properties;
+
+public final class TestQueryAssistedShardingEncryptAlgorithm implements
QueryAssistedEncryptAlgorithm<Object, String> {
+
+ @Getter
+ @Setter
+ private Properties props;
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public String encrypt(final Object plainValue) {
+ return "encryptValue";
+ }
+
+ @Override
+ public Object decrypt(final String cipherValue) {
+ return "decryptValue";
+ }
+
+ @Override
+ public String queryAssistedEncrypt(final Object plainValue) {
+ return "assistedEncryptValue";
+ }
+
+ @Override
+ public String getType() {
+ return "assistedTest";
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/entity/User.java
similarity index 93%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/entity/User.java
index f7e0660..e054331 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/User.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/entity/User.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
+package
org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.entity;
import java.io.Serializable;
@@ -24,9 +24,9 @@ public class User implements Serializable {
private static final long serialVersionUID = 263434701950670170L;
private int userId;
-
+
private String userName;
-
+
private String pwd;
public int getUserId() {
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/repository/UserRepository.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphe
[...]
new file mode 100644
index 0000000..0cf0ce2
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/encrypt/springboot/starter/mybatis/repository/UserRepository.java
@@ -0,0 +1,39 @@
+/*
+ * 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.encrypt.springboot.starter.mybatis.repository;
+
+import org.apache.ibatis.annotations.Mapper;
+import
org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.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-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-exa
[...]
similarity index 87%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index 2d0feb8..0ac9b95 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.example.encrypt.spring.namespace.mybatis.TestQueryAssistedShardingEncryptAlgorithm
\ No newline at end of file
+org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.TestQueryAssistedShardingEncryptAlgorithm
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/application.properties
similarity index 70%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/application.properties
index 27f3f3d..8b0925d 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/application.properties
@@ -15,10 +15,8 @@
# limitations under the License.
#
-<#if framework?contains("mybatis")>
mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
-</#if>
spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
@@ -33,14 +31,14 @@ spring.shardingsphere.datasource.ds-1.username=root
spring.shardingsphere.datasource.ds-1.password=root
spring.shardingsphere.datasource.ds-1.max-active=16
-<#if feature=="sharding">
-spring.shardingsphere.schema.name=sharding
+spring.shardingsphere.datasource.names=ds-0
+
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=assistedTest
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
- <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
-spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
-
- <#include "readwriteSplittingApplication.ftl">
-</#if>
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.assisted-query-column=assisted_query_pwd
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/logback.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shard
[...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger]
%msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/mappers/UserMapper.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-ex
[...]
new file mode 100644
index 0000000..c3856c9
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-encrypt-example/shardingsphere-jdbc-memory-local-encrypt-springboot-starter-mybatis-example/src/main/resources/mappers/UserMapper.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper
namespace="org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.repository.UserRepository">
+ <resultMap id="baseResultMap"
type="org.apache.shardingsphere.example.encrypt.springboot.starter.mybatis.entity.User">
+ <result column="user_id" property="userId" jdbcType="INTEGER"/>
+ <result column="user_name" property="userName" jdbcType="VARCHAR"/>
+ <result column="pwd" property="pwd" jdbcType="VARCHAR"/>
+ <result column="assisted_query_pwd" property="assistedQueryPwd"
jdbcType="VARCHAR"/>
+ </resultMap>
+
+ <update id="createTableIfNotExists">
+ CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL
AUTO_INCREMENT, user_name VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY
(user_id));
+ </update>
+
+ <update id="truncateTable">
+ TRUNCATE TABLE t_user;
+ </update>
+
+ <update id="dropTable">
+ DROP TABLE IF EXISTS t_user;
+ </update>
+
+ <insert id="insert">
+ INSERT INTO t_user (user_id, user_name, pwd) VALUES
(#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
#{pwd,jdbcType=VARCHAR})
+ </insert>
+
+ <delete id="delete">
+ DELETE FROM t_user WHERE user_id = #{userId,jdbcType=INTEGER};
+ </delete>
+
+ <select id="selectAll" resultMap="baseResultMap">
+ SELECT * FROM t_user;
+ </select>
+</mapper>