You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/11/18 02:26:16 UTC
[shardingsphere] branch master updated: Add more example module for readwrite-splitting (#13671)
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 e695c1e Add more example module for readwrite-splitting (#13671)
e695c1e is described below
commit e695c1e71db3c39675b153b4678839af19d9307a
Author: Guocheng Tang <to...@qq.com>
AuthorDate: Thu Nov 18 10:25:16 2021 +0800
Add more example module for readwrite-splitting (#13671)
* Add more example module for readwrite-splitting
* Add more example module for readwrite-splitting
* revert package
* fix ci
* update package
---
.../engine/SpringbootStarterJDBCGenerator.java | 2 +
.../engine/SpringbootStarterJpaGenerator.java | 2 +
.../engine/SpringbootStarterMybatisGenerator.java | 1 +
.../dataModel/spring-namespace-jpa/data-model.yaml | 2 +-
.../spring-namespace-mybatis/data-model.yaml | 2 +-
.../springboot-starter-jdbc/data-model.yaml | 6 +-
.../springboot-starter-jpa/data-model.yaml | 2 +-
.../springboot-starter-mybatis/data-model.yaml | 2 +-
.../src/main/resources/template/Example.ftl | 4 +-
.../src/main/resources/template/ExampleService.ftl | 16 +-
.../main/resources/template/jpa/ExampleService.ftl | 14 +-
.../src/main/resources/template/jpa/Repository.ftl | 12 +-
.../resources/template/mappers/OrderItemMapper.ftl | 4 +-
.../resources/template/mappers/OrderMapper.ftl | 4 +-
.../template/mybatis/OrderItemRepository.ftl | 4 +-
.../resources/template/mybatis/OrderRepository.ftl | 4 +-
.../resources/template/properties/application.ftl | 53 ++---
.../properties/readwriteSplittingApplication.ftl | 26 +++
.../template/properties/shardingApplication.ftl | 45 ++++
.../main/resources/template/xml/application.ftl | 5 +-
.../template/xml/readwriteSplittingApplication.ftl | 2 +-
.../pom.xml | 5 +
.../src/main/resources/application.xml | 12 +-
.../pom.xml | 35 ++--
...adwriteSplittingSpringNamespaceJpaExample.java} | 29 +--
...SplittingSpringNamespaceJpaExampleService.java} | 14 +-
...riteSplittingSpringNamespaceJpaRepository.java} | 12 +-
.../spring/namespace/jpa/entity/Order.java | 84 ++++++++
.../spring/namespace/jpa/entity/OrderItem.java | 84 ++++++++
.../src/main/resources/application.xml} | 40 ++--
.../src/main/resources/logback.xml} | 32 ++-
.../pom.xml | 30 +--
...iteSplittingSpringNamespaceMybatisExample.java} | 29 +--
...ttingSpringNamespaceMybatisExampleService.java} | 16 +-
.../spring/namespace/mybatis/entity/Order.java | 70 +++++++
.../spring/namespace/mybatis/entity/OrderItem.java | 70 +++++++
.../mybatis/repository/OrderItemRepository.java} | 4 +-
.../mybatis/repository/OrderRepository.java} | 4 +-
.../src/main/resources/application.xml | 29 ++-
.../src/main/resources/logback.xml} | 32 ++-
.../main/resources/mappers/OrderItemMapper.xml} | 8 +-
.../src/main/resources/mappers/OrderMapper.xml} | 8 +-
.../pom.xml | 4 +-
...writeSplittingSpringbootStarterJdbcExample.java | 34 +++
...littingSpringbootStarterJdbcExampleService.java | 227 +++++++++++++++++++++
.../springboot/starter/jdbc/entity/Order.java | 70 +++++++
.../springboot/starter/jdbc/entity/OrderItem.java | 70 +++++++
.../src/main/resources/application.properties | 43 ++++
.../src/main/resources/logback.xml} | 32 ++-
.../pom.xml | 30 +--
...dwriteSplittingSpringbootStarterJpaExample.java | 36 ++++
...littingSpringbootStarterJpaExampleService.java} | 14 +-
...teSplittingSpringbootStarterJpaRepository.java} | 12 +-
.../springboot/starter/jpa/entity/Order.java | 84 ++++++++
.../springboot/starter/jpa/entity/OrderItem.java | 84 ++++++++
.../src/main/resources/application.properties | 43 ++++
.../src/main/resources/logback.xml} | 32 ++-
.../pom.xml | 19 +-
...teSplittingSpringbootStarterMybatisExample.java | 36 ++++
...ingSpringbootStarterMybatisExampleService.java} | 16 +-
.../springboot/starter/mybatis/entity/Order.java | 70 +++++++
.../starter/mybatis/entity/OrderItem.java | 70 +++++++
.../mybatis/repository/OrderItemRepository.java} | 4 +-
.../mybatis/repository/OrderRepository.java} | 4 +-
.../src/main/resources/application.properties | 45 ++++
.../src/main/resources/logback.xml} | 32 ++-
.../main/resources/mappers/OrderItemMapper.xml} | 8 +-
.../src/main/resources/mappers/OrderMapper.xml} | 8 +-
.../pom.xml | 5 -
69 files changed, 1619 insertions(+), 372 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 d1815f0..3aa7da3 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,6 +35,8 @@ 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");
+
+ RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
public SpringbootStarterJDBCGenerator() {
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 6e12afe..28a2ab1 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,8 @@ 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");
+
+ RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
public SpringbootStarterJpaGenerator() {
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 90072f1..acb7955 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
@@ -40,6 +40,7 @@ public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngi
RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper", "mappers/OrderItemMapper.xml");
RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderItemMapper.xml");
+ RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
public SpringbootStarterMybatisGenerator() {
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
index 10fb892..f822bc9 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-jpa/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: sharding
+feature: readwrite-splitting
framework: spring-namespace-jpa
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
index e5ec759..8c8982d 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-namespace-mybatis/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: sharding
+feature: readwrite-splitting
framework: spring-namespace-mybatis
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 58405a2..3083fa6 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,10 +17,6 @@
mode: memory
transaction: local
-feature: sharding
+feature: readwrite-splitting
framework: springboot-starter-jdbc
-host: localhost
-port: 3306
-username: root
-password: 123456
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 27d2be1..a090d11 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: sharding
+feature: readwrite-splitting
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 6d18061..1485b0f 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: sharding
+feature: readwrite-splitting
framework: springboot-starter-mybatis
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
index e6eb6ec..738a519 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
@@ -44,10 +44,10 @@ import java.sql.SQLException;
<#assign featureName=featureName + feature1?cap_first>
</#list>
<#if framework=="springboot-starter-mybatis">
-@MapperScan("org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository")
+@MapperScan("org.apache.shardingsphere.example.${feature?replace('-', '.')}.springboot.starter.mybatis.repository")
</#if>
<#if framework=="springboot-starter-jpa">
-@EntityScan(basePackages = "org.apache.shardingsphere.example.${feature}.springboot.starter.jpa.entity")
+@EntityScan(basePackages = "org.apache.shardingsphere.example.${feature?replace('-', '.')}.springboot.starter.jpa.entity")
</#if>
<#if framework?contains("springboot")>
@SpringBootApplication
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 ec420c8..2b7d9af 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
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')};
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository.OrderItemRepository;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository.OrderRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -32,8 +32,12 @@ import java.util.List;
<#list framework?split("-") as framework1>
<#assign frameworkName=frameworkName + framework1?cap_first>
</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class ${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService {
@Resource
private OrderRepository orderRepository;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
index 924821c..c6e82ad 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')};
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.OrderItem;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -29,11 +29,15 @@ import java.util.List;
<#list framework?split("-") as framework1>
<#assign frameworkName=frameworkName + framework1?cap_first>
</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class ${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService {
@Resource
- private ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository repository;
+ private ${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository repository;
/**
* Execute test.
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
index 0aaebfa..19c36ac 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')};
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.OrderItem;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
@@ -31,9 +31,13 @@ import java.util.List;
<#list framework?split("-") as framework1>
<#assign frameworkName=frameworkName + framework1?cap_first>
</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
@Repository
@Transactional
-public class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository {
+public class ${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Repository {
@PersistenceContext
private EntityManager entityManager;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
index d901a06..b690971 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem">
+<mapper namespace="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository.OrderItemRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.OrderItem">
<result column="order_item_id" property="orderItemId" jdbcType="INTEGER"/>
<result column="order_id" property="orderId" jdbcType="INTEGER"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
index b089fcc..5bad8c1 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order">
+<mapper namespace="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository.OrderRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.Order">
<result column="order_id" property="orderId" jdbcType="BIGINT"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
<result column="address_id" property="addressId" jdbcType="BIGINT"/>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
index 946298e..8214d32 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.OrderItem;
import java.util.List;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
index ad58a50..213bee2 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity.Order;
import java.util.List;
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 53af793..27f3f3d 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
@@ -15,57 +15,32 @@
# limitations under the License.
#
+<#if framework?contains("mybatis")>
mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
-spring.shardingsphere.schema.name=sharding
-
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
+</#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:3307/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=123456
+spring.shardingsphere.datasource.ds-0.password=root
spring.shardingsphere.datasource.ds-0.max-active=16
spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3307/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=123456
+spring.shardingsphere.datasource.ds-1.password=root
spring.shardingsphere.datasource.ds-1.max-active=16
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-
-spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-inline
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+<#if feature=="sharding">
+spring.shardingsphere.schema.name=sharding
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
+spring.shardingsphere.datasource.names=ds-0,ds-1
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
+ <#include "shardingApplication.ftl">
+<#elseif feature=="readwrite-splitting">
+spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
-spring.shardingsphere.rules.encrypt.encryptors.status-encryptor.type=AES
-spring.shardingsphere.rules.encrypt.encryptors.status-encryptor.props.aes-key-value=123456
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.status.cipher-column=status
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.status.encryptor-name=status-encryptor
+ <#include "readwriteSplittingApplication.ftl">
+</#if>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/readwriteSplittingApplication.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/readwriteSplittingApplication.ftl
new file mode 100644
index 0000000..5ab4d40
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/readwriteSplittingApplication.ftl
@@ -0,0 +1,26 @@
+<#--
+ ~ 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.datasource.ds-2.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-2.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-2.username=root
+spring.shardingsphere.datasource.ds-2.password=root
+
+spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-source-name=ds-0
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=ds-1,ds-2
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.load-balancer-name=round_robin
\ No newline at end of file
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shardingApplication.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shardingApplication.ftl
new file mode 100644
index 0000000..bcedd9b
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shardingApplication.ftl
@@ -0,0 +1,45 @@
+<#--
+ ~ 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.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
+
+spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
+spring.shardingsphere.rules.sharding.broadcast-tables=t_address
+
+spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
+
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-inline
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
+
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
\ No newline at end of file
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
index 1b2a735..ef111df 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
@@ -45,7 +45,7 @@
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:database="MYSQL" />
</property>
- <property name="packagesToScan" value="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity" />
+ <property name="packagesToScan" value="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.entity" />
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
@@ -71,7 +71,6 @@
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>
-
<#if feature=="sharding">
<#include "shardingApplication.ftl">
<#elseif feature=="readwrite-splitting">
@@ -90,7 +89,7 @@
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository"/>
+ <property name="basePackage" value="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</#if>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwriteSplittingApplication.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwriteSplittingApplication.ftl
index 23a8a04..33276cd 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwriteSplittingApplication.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/readwriteSplittingApplication.ftl
@@ -17,7 +17,7 @@
<bean id="demo_ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_read_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
index 6d77c6d..52033f8 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
@@ -32,5 +32,10 @@
<modules>
<module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
<module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
+ <module>shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example</module>
+ <module>shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example</module>
+ <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example</module>
+ <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example</module>
+ <module>shardingsphere-jdbc-memory-local-readwrite-splitting-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-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-loca [...]
index 499a567..702c78a 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml
@@ -42,24 +42,24 @@
<bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
<bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
<bean id="demo_ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_read_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
<readwrite-splitting:load-balance-algorithm id="randomStrategy" type="RANDOM" />
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jd [...]
similarity index 62%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/pom.xml
index 8a31cf6..533f176 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/pom.xml
@@ -20,33 +20,38 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-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-sharding-springboot-starter-jdbc-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example</artifactId>
<name>${project.artifactId}</name>
-
+
<dependencies>
<dependency>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>example-raw-jdbc</artifactId>
- <version>${project.version}</version>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-autoconfigure</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/names [...]
similarity index 51%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaExample.java
index 946298e..e6558e9 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaExample.java
@@ -15,25 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.sql.SQLException;
-import java.util.List;
-
-@Mapper
-public interface OrderItemRepository {
-
- void createTableIfNotExists();
-
- void truncateTable();
-
- void dropTable();
-
- void insert(OrderItem orderItem);
-
- void delete(long orderId);
+public class MemoryLocalReadwriteSplittingSpringNamespaceJpaExample {
- List<OrderItem> selectAll();
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml")) {
+ MemoryLocalReadwriteSplittingSpringNamespaceJpaExampleService exampleService = applicationContext.getBean(MemoryLocalReadwriteSplittingSpringNamespaceJpaExampleService.class);
+ exampleService.run();
+ }
+ }
}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/ [...]
similarity index 81%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaExampleService.java
index 924821c..4f5e7d5 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaExampleService.java
@@ -15,25 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity.OrderItem;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class MemoryLocalReadwriteSplittingSpringNamespaceJpaExampleService {
@Resource
- private ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository repository;
+ private MemoryLocalReadwriteSplittingSpringNamespaceJpaRepository repository;
/**
* Execute test.
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/Memo [...]
similarity index 80%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaRepository.java
index 0aaebfa..cf1b426 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/MemoryLocalReadwriteSplittingSpringNamespaceJpaRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity.OrderItem;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
@@ -27,13 +27,9 @@ import javax.persistence.Query;
import javax.transaction.Transactional;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Repository
@Transactional
-public class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository {
+public class MemoryLocalReadwriteSplittingSpringNamespaceJpaRepository {
@PersistenceContext
private EntityManager entityManager;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/s [...]
new file mode 100644
index 0000000..1807c56
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/entity/Order.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "t_order")
+public class Order implements Serializable {
+
+ private static final long serialVersionUID = 8306802022239174861L;
+
+ @Id
+ @Column(name = "order_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long orderId;
+
+ @Column(name = "user_id")
+ private int userId;
+
+ @Column(name = "address_id")
+ private long addressId;
+
+ @Column(name = "status")
+ private String status;
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public long getAddressId() {
+ return addressId;
+ }
+
+ public void setAddressId(final long addressId) {
+ this.addressId = addressId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-examp [...]
new file mode 100644
index 0000000..69eddb9
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/jpa/entity/OrderItem.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "t_order_item")
+public class OrderItem implements Serializable {
+
+ private static final long serialVersionUID = 1332162822494069342L;
+
+ @Id
+ @Column(name = "order_item_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long orderItemId;
+
+ @Column(name = "order_id")
+ private long orderId;
+
+ @Column(name = "user_id")
+ private int userId;
+
+ @Column(name = "status")
+ private String status;
+
+ public long getOrderItemId() {
+ return orderItemId;
+ }
+
+ public void setOrderItemId(final long orderItemId) {
+ this.orderItemId = orderItemId;
+ }
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/resources/application.xml
similarity index 80%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/resources/application.xml
index 1b2a735..4eb983c 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/xml/application.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/resources/application.xml
@@ -38,14 +38,13 @@
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
">
<context:annotation-config />
- <context:component-scan base-package="org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')}"/>
-<#if framework=="spring-namespace-jpa">
+ <context:component-scan base-package="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jpa"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:database="MYSQL" />
</property>
- <property name="packagesToScan" value="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity" />
+ <property name="packagesToScan" value="org.apache.shardingsphere.example.readwrite-splitting.spring.namespace.jpa.entity" />
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
@@ -56,7 +55,6 @@
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
<tx:annotation-driven />
-</#if>
<bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
@@ -72,26 +70,20 @@
<property name="password" value="123456"/>
</bean>
-<#if feature=="sharding">
- <#include "shardingApplication.ftl">
-<#elseif feature=="readwrite-splitting">
- <#include "readwriteSplittingApplication.ftl">
-</#if>
-<#if framework=="spring-namespace-mybatis">
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
- <tx:annotation-driven />
-
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
- </bean>
-
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository"/>
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
+ <bean id="demo_ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
+ <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="username" value="root"/>
+ <property name="password" value=""/>
</bean>
-</#if>
+
+ <readwrite-splitting:load-balance-algorithm id="randomStrategy" type="RANDOM" />
+
+ <readwrite-splitting:rule id="readWriteSplittingRule">
+ <readwrite-splitting:data-source-rule id="demo_ds" write-data-source-name="demo_ds_0" read-data-source-names="demo_ds_1, demo_ds_2" load-balance-algorithm-ref="randomStrategy" />
+ </readwrite-splitting:rule>
+
+ <shardingsphere:data-source id="dataSource" data-source-names="demo_ds_0, demo_ds_1, demo_ds_2" rule-refs="readWriteSplittingRule" />
+
</beans>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-exampl [...]
similarity index 50%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/resources/logback.xml
index 6d77c6d..1c4b005 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jpa-example/src/main/resources/logback.xml
@@ -16,21 +16,19 @@
~ 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-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-readwrite-splitting-example</artifactId>
- <name>${project.artifactId}</name>
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example-engine" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
+ <contextName>${log.context.name}</contextName>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
- </modules>
-</project>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jd [...]
similarity index 67%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
index 8a31cf6..b2afec7 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
@@ -20,33 +20,33 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-local-sharding-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-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-sharding-springboot-starter-jdbc-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example</artifactId>
<name>${project.artifactId}</name>
-
<dependencies>
<dependency>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>example-raw-jdbc</artifactId>
- <version>${project.version}</version>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.mybatis</groupId>
+ <artifactId>mybatis</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-autoconfigure</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.mybatis</groupId>
+ <artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/n [...]
similarity index 51%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/MemoryLocalReadwriteSplittingSpringNamespaceMybatisExample.java
index 946298e..7951dda 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/MemoryLocalReadwriteSplittingSpringNamespaceMybatisExample.java
@@ -15,25 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.sql.SQLException;
-import java.util.List;
-
-@Mapper
-public interface OrderItemRepository {
-
- void createTableIfNotExists();
-
- void truncateTable();
-
- void dropTable();
-
- void insert(OrderItem orderItem);
-
- void delete(long orderId);
+public class MemoryLocalReadwriteSplittingSpringNamespaceMybatisExample {
- List<OrderItem> selectAll();
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml")) {
+ MemoryLocalReadwriteSplittingSpringNamespaceMybatisExampleService exampleService = applicationContext.getBean(MemoryLocalReadwriteSplittingSpringNamespaceMybatisExampleService.class);
+ exampleService.run();
+ }
+ }
}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/myba [...]
similarity index 83%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/MemoryLocalReadwriteSplittingSpringNamespaceMybatisExampleService.java
index ec420c8..32b617a 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/MemoryLocalReadwriteSplittingSpringNamespaceMybatisExampleService.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.repository.OrderItemRepository;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.repository.OrderRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -28,12 +28,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class MemoryLocalReadwriteSplittingSpringNamespaceMybatisExampleService {
@Resource
private OrderRepository orderRepository;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-e [...]
new file mode 100644
index 0000000..d56d1b5
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/entity/Order.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity;
+
+import java.io.Serializable;
+
+public class Order implements Serializable {
+
+ private static final long serialVersionUID = 8306802022239174861L;
+
+ private long orderId;
+
+ private int userId;
+
+ private long addressId;
+
+ private String status;
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public long getAddressId() {
+ return addressId;
+ }
+
+ public void setAddressId(final long addressId) {
+ this.addressId = addressId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memo [...]
new file mode 100644
index 0000000..59c6faf
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/entity/OrderItem.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity;
+
+import java.io.Serializable;
+
+public class OrderItem implements Serializable {
+
+ private static final long serialVersionUID = 1332162822494069342L;
+
+ private long orderItemId;
+
+ private long orderId;
+
+ private int userId;
+
+ private String status;
+
+ public long getOrderItemId() {
+ return orderItemId;
+ }
+
+ public void setOrderItemId(final long orderItemId) {
+ this.orderItemId = orderItemId;
+ }
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/n [...]
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/repository/OrderItemRepository.java
index 946298e..f041f48 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/repository/OrderItemRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.OrderItem;
import java.util.List;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/names [...]
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/repository/OrderRepository.java
index ad58a50..32052f2 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace/mybatis/repository/OrderRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.Order;
import java.util.List;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-loca [...]
similarity index 78%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/application.xml
index 499a567..c1b944d 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example/src/main/resources/application.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/application.xml
@@ -38,28 +38,27 @@
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
">
<context:annotation-config />
- <context:component-scan base-package="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.jdbc"/>
+ <context:component-scan base-package="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis"/>
<bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
<bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
-
<bean id="demo_ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3307/demo_read_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
+ <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
- <property name="password" value="123456"/>
+ <property name="password" value="root"/>
</bean>
<readwrite-splitting:load-balance-algorithm id="randomStrategy" type="RANDOM" />
@@ -70,4 +69,18 @@
<shardingsphere:data-source id="dataSource" data-source-names="demo_ds_0, demo_ds_1, demo_ds_2" rule-refs="readWriteSplittingRule" />
+ <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+ <tx:annotation-driven />
+
+ <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+ <property name="dataSource" ref="dataSource"/>
+ <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
+ </bean>
+
+ <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+ <property name="basePackage" value="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.repository"/>
+ <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
+ </bean>
</beans>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-ex [...]
similarity index 50%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/logback.xml
index 6d77c6d..1c4b005 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/logback.xml
@@ -16,21 +16,19 @@
~ 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-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-readwrite-splitting-example</artifactId>
- <name>${project.artifactId}</name>
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example-engine" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
+ <contextName>${log.context.name}</contextName>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
- </modules>
-</project>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
index d901a06..2084e75 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem">
+<mapper namespace="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderItemRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.OrderItem">
<result column="order_item_id" property="orderItemId" jdbcType="INTEGER"/>
<result column="order_id" property="orderId" jdbcType="INTEGER"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
@@ -38,11 +38,11 @@
</update>
<insert id="insert" useGeneratedKeys="true" keyProperty="orderItemId">
- INSERT INTO t_order_item (order_id, user_id, status) VALUES (${r"#{orderId,jdbcType=INTEGER}"}, ${r"#{userId,jdbcType=INTEGER}"}, ${r"#{status,jdbcType=VARCHAR}"});
+ INSERT INTO t_order_item (order_id, user_id, status) VALUES (#{orderId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR});
</insert>
<delete id="delete">
- DELETE FROM t_order_item WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+ DELETE FROM t_order_item WHERE order_id = #{orderId,jdbcType=INTEGER};
</delete>
<select id="selectAll" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
index b089fcc..e7f4e45 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/mappers/OrderMapper.xml
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order">
+<mapper namespace="org.apache.shardingsphere.example.sharding.spring.namespace.mybatis.repository.OrderRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.readwrite.splitting.spring.namespace.mybatis.entity.Order">
<result column="order_id" property="orderId" jdbcType="BIGINT"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
<result column="address_id" property="addressId" jdbcType="BIGINT"/>
@@ -38,11 +38,11 @@
</update>
<insert id="insert" useGeneratedKeys="true" keyProperty="orderId">
- INSERT INTO t_order (user_id, address_id, status) VALUES (${r"#{userId,jdbcType=INTEGER}"}, ${r"#{addressId,jdbcType=BIGINT}"}, ${r"#{status,jdbcType=VARCHAR}"});
+ INSERT INTO t_order (user_id, address_id, status) VALUES (#{userId,jdbcType=INTEGER}, #{addressId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR});
</insert>
<delete id="delete">
- DELETE FROM t_order WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+ DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER};
</delete>
<select id="selectAll" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jd [...]
similarity index 90%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/pom.xml
index 8a31cf6..106e301 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/pom.xml
@@ -20,12 +20,12 @@
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-sharding-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-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-sharding-springboot-starter-jdbc-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example</artifactId>
<name>${project.artifactId}</name>
<dependencies>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/MemoryLocalReadwriteSplittingSpringbootStarterJdbcExample.java b/examples/shardingsphere-sample/shardingsphe [...]
new file mode 100644
index 0000000..8010ef0
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/MemoryLocalReadwriteSplittingSpringbootStarterJdbcExample.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.readwrite.splitting.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 MemoryLocalReadwriteSplittingSpringbootStarterJdbcExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalReadwriteSplittingSpringbootStarterJdbcExample.class, args)) {
+ MemoryLocalReadwriteSplittingSpringbootStarterJdbcExampleService exampleService = applicationContext.getBean(MemoryLocalReadwriteSplittingSpringbootStarterJdbcExampleService.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-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/MemoryLocalReadwriteSplittingSpringbootStarterJdbcExampleService.java b/examples/shardingsphere-sample/shard [...]
new file mode 100644
index 0000000..b07d670
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/MemoryLocalReadwriteSplittingSpringbootStarterJdbcExampleService.java
@@ -0,0 +1,227 @@
+/*
+ * 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.readwrite.splitting.springboot.starter.jdbc;
+
+import lombok.AllArgsConstructor;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jdbc.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jdbc.entity.OrderItem;
+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 MemoryLocalReadwriteSplittingSpringbootStarterJdbcExampleService {
+
+ 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 createOrderTableSql = "CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT NULL AUTO_INCREMENT, user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id))";
+ String createOrderItemTableSql = "CREATE TABLE IF NOT EXISTS t_order_item "
+ + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_item_id))";
+ String createAddressTableSql = "CREATE TABLE IF NOT EXISTS t_address "
+ + "(address_id BIGINT NOT NULL, address_name VARCHAR(100) NOT NULL, PRIMARY KEY (address_id))";
+ String truncateOrderTable = "TRUNCATE TABLE t_order";
+ String truncateOrderItemTable = "TRUNCATE TABLE t_order_item";
+ String truncateAddressTableSql = "TRUNCATE TABLE t_address";
+
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(createOrderTableSql);
+ statement.executeUpdate(createOrderItemTableSql);
+ statement.executeUpdate(createAddressTableSql);
+ statement.executeUpdate(createAddressTableSql);
+ statement.executeUpdate(truncateOrderTable);
+ statement.executeUpdate(truncateOrderItemTable);
+ statement.executeUpdate(truncateAddressTableSql);
+ }
+ }
+
+ private void processSuccess() throws SQLException {
+ System.out.println("-------------- Process Success Begin ---------------");
+ List<Long> orderIds = insertData();
+ printData();
+ deleteData(orderIds);
+ printData();
+ System.out.println("-------------- Process Success Finish --------------");
+ }
+
+ private void processFailure() throws SQLException {
+ System.out.println("-------------- Process Failure Begin ---------------");
+ insertData();
+ System.out.println("-------------- Process Failure Finish --------------");
+ throw new RuntimeException("Exception occur for transaction test.");
+ }
+
+ private List<Long> insertData() throws SQLException {
+ System.out.println("---------------------------- Insert Data ----------------------------");
+ List<Long> result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ Order order = insertOrder(i);
+ insertOrderItem(i, order);
+ result.add(order.getOrderId());
+ }
+ return result;
+ }
+
+ private Order insertOrder(final int i) throws SQLException {
+ Order order = new Order();
+ order.setUserId(i);
+ order.setAddressId(i);
+ order.setStatus("INSERT_TEST");
+ String sql = "INSERT INTO t_order (user_id, address_id, status) VALUES (?, ?, ?)";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+ preparedStatement.setInt(1, order.getUserId());
+ preparedStatement.setLong(2, order.getAddressId());
+ preparedStatement.setString(3, order.getStatus());
+ preparedStatement.executeUpdate();
+ try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
+ if (resultSet.next()) {
+ order.setOrderId(resultSet.getLong(1));
+ }
+ }
+ }
+ return order;
+ }
+
+ private void insertOrderItem(final int i, final Order order) throws SQLException {
+ OrderItem orderItem = new OrderItem();
+ orderItem.setOrderId(order.getOrderId());
+ orderItem.setUserId(i);
+ orderItem.setStatus("INSERT_TEST");
+ String sql = "INSERT INTO t_order_item (order_id, user_id, status) VALUES (?, ?, ?)";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+ preparedStatement.setLong(1, orderItem.getOrderId());
+ preparedStatement.setInt(2, orderItem.getUserId());
+ preparedStatement.setString(3, orderItem.getStatus());
+ preparedStatement.executeUpdate();
+ try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
+ if (resultSet.next()) {
+ orderItem.setOrderItemId(resultSet.getLong(1));
+ }
+ }
+ }
+ }
+
+ private void deleteData(final List<Long> orderIds) throws SQLException {
+ System.out.println("---------------------------- Delete Data ----------------------------");
+ for (Long each : orderIds) {
+ String deleteOrderSql = "DELETE FROM t_order WHERE order_id=?";
+ String deleteOrderItemSql = "DELETE FROM t_order_item WHERE order_id=?";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement orderPreparedStatement = connection.prepareStatement(deleteOrderSql);
+ PreparedStatement orderItemPreparedStatement = connection.prepareStatement(deleteOrderItemSql)) {
+ orderPreparedStatement.setLong(1, each);
+ orderItemPreparedStatement.setLong(1, each);
+ orderPreparedStatement.executeUpdate();
+ orderItemPreparedStatement.executeUpdate();
+ }
+ }
+ }
+
+ private void printData() throws SQLException {
+ System.out.println("---------------------------- Print Order Data -----------------------");
+ for (Object each : this.getOrders()) {
+ System.out.println(each);
+ }
+ System.out.println("---------------------------- Print OrderItem Data -------------------");
+ for (Object each : this.getOrderItems()) {
+ System.out.println(each);
+ }
+ }
+
+ protected List<OrderItem> getOrderItems() throws SQLException {
+ String sql = "SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id";
+ List<OrderItem> result = new LinkedList<>();
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ OrderItem orderItem = new OrderItem();
+ orderItem.setOrderItemId(resultSet.getLong(1));
+ orderItem.setOrderId(resultSet.getLong(2));
+ orderItem.setUserId(resultSet.getInt(3));
+ orderItem.setStatus(resultSet.getString(4));
+ result.add(orderItem);
+ }
+ }
+ return result;
+ }
+
+ protected List<Order> getOrders() throws SQLException {
+ String sql = "SELECT * FROM t_order";
+ List<Order> result = new LinkedList<>();
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ Order order = new Order();
+ order.setOrderId(resultSet.getLong(1));
+ order.setUserId(resultSet.getInt(2));
+ order.setAddressId(resultSet.getLong(3));
+ order.setStatus(resultSet.getString(4));
+ result.add(order);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Restore the environment.
+ * @throws SQLException
+ */
+ private void cleanEnvironment() throws SQLException {
+ String dropOrderSql = "DROP TABLE t_order";
+ String dropOrderItemSql = "DROP TABLE t_order_item";
+ String dropAddressSql = "DROP TABLE t_address";
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(dropOrderSql);
+ statement.executeUpdate(dropOrderItemSql);
+ statement.executeUpdate(dropAddressSql);
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-exa [...]
new file mode 100644
index 0000000..0a7fa23
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/entity/Order.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jdbc.entity;
+
+import java.io.Serializable;
+
+public class Order implements Serializable {
+
+ private static final long serialVersionUID = 8306802022239174861L;
+
+ private long orderId;
+
+ private int userId;
+
+ private long addressId;
+
+ private String status;
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public long getAddressId() {
+ return addressId;
+ }
+
+ public void setAddressId(final long addressId) {
+ this.addressId = addressId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory [...]
new file mode 100644
index 0000000..218e089
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jdbc/entity/OrderItem.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jdbc.entity;
+
+import java.io.Serializable;
+
+public class OrderItem implements Serializable {
+
+ private static final long serialVersionUID = 1332162822494069342L;
+
+ private long orderItemId;
+
+ private long orderId;
+
+ private int userId;
+
+ private String status;
+
+ public long getOrderItemId() {
+ return orderItemId;
+ }
+
+ public void setOrderItemId(final long orderItemId) {
+ this.orderItemId = orderItemId;
+ }
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-me [...]
new file mode 100644
index 0000000..9926c45
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/resources/application.properties
@@ -0,0 +1,43 @@
+#
+# 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.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:3307/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
+
+spring.shardingsphere.datasource.ds-2.jdbc-url=jdbc:mysql://localhost:3306/ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-2.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-2.username=root
+spring.shardingsphere.datasource.ds-2.password=root
+
+spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-source-name=ds-0
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=ds-1,ds-2
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.load-balancer-name=round_robin
\ No newline at end of file
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-exa [...]
similarity index 50%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/resources/logback.xml
index 6d77c6d..154abba 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jdbc-example/src/main/resources/logback.xml
@@ -16,21 +16,19 @@
~ 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-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-readwrite-splitting-example</artifactId>
- <name>${project.artifactId}</name>
+<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>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
- </modules>
-</project>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jd [...]
similarity index 72%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/pom.xml
index 8a31cf6..439b8f7 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/pom.xml
@@ -20,33 +20,35 @@
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-sharding-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-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-sharding-springboot-starter-jdbc-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>example-raw-jdbc</artifactId>
- <version>${project.version}</version>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-autoconfigure</artifactId>
- <version>2.2.0.RELEASE</version>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
+
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaExample.java b/examples/shardingsphere-sample/shardingsphere- [...]
new file mode 100644
index 0000000..e84ad4e
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaExample.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.readwrite.splitting.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.readwrite.splitting.springboot.starter.jpa.entity")
+@SpringBootApplication
+public class MemoryLocalReadwriteSplittingSpringbootStarterJpaExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalReadwriteSplittingSpringbootStarterJpaExample.class, args)) {
+ MemoryLocalReadwriteSplittingSpringbootStarterJpaExampleService exampleService = applicationContext.getBean(MemoryLocalReadwriteSplittingSpringbootStarterJpaExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/ [...]
similarity index 81%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaExampleService.java
index 924821c..11c9b30 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaExampleService.java
@@ -15,25 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa.entity.OrderItem;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class MemoryLocalReadwriteSplittingSpringbootStarterJpaExampleService {
@Resource
- private ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository repository;
+ private MemoryLocalReadwriteSplittingSpringbootStarterJpaRepository repository;
/**
* Execute test.
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/ [...]
similarity index 80%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaRepository.java
index 0aaebfa..0072ce2 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jpa/Repository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/MemoryLocalReadwriteSplittingSpringbootStarterJpaRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.jpa.entity.OrderItem;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
@@ -27,13 +27,9 @@ import javax.persistence.Query;
import javax.transaction.Transactional;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Repository
@Transactional
-public class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Repository {
+public class MemoryLocalReadwriteSplittingSpringbootStarterJpaRepository {
@PersistenceContext
private EntityManager entityManager;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-examp [...]
new file mode 100644
index 0000000..df56e72
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/entity/Order.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.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_order")
+public class Order implements Serializable {
+
+ private static final long serialVersionUID = 8306802022239174861L;
+
+ @Id
+ @Column(name = "order_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long orderId;
+
+ @Column(name = "user_id")
+ private int userId;
+
+ @Column(name = "address_id")
+ private long addressId;
+
+ @Column(name = "status")
+ private String status;
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public long getAddressId() {
+ return addressId;
+ }
+
+ public void setAddressId(final long addressId) {
+ this.addressId = addressId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-e [...]
new file mode 100644
index 0000000..464481f
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/jpa/entity/OrderItem.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.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_order_item")
+public class OrderItem implements Serializable {
+
+ private static final long serialVersionUID = 1332162822494069342L;
+
+ @Id
+ @Column(name = "order_item_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long orderItemId;
+
+ @Column(name = "order_id")
+ private long orderId;
+
+ @Column(name = "user_id")
+ private int userId;
+
+ @Column(name = "status")
+ private String status;
+
+ public long getOrderItemId() {
+ return orderItemId;
+ }
+
+ public void setOrderItemId(final long orderItemId) {
+ this.orderItemId = orderItemId;
+ }
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-mem [...]
new file mode 100644
index 0000000..fe3cd9b
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/resources/application.properties
@@ -0,0 +1,43 @@
+#
+# 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.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
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
+
+spring.shardingsphere.datasource.ds-2.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-2.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-2.username=root
+spring.shardingsphere.datasource.ds-2.password=root
+
+spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-source-name=ds-0
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=ds-1,ds-2
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.load-balancer-name=round_robin
\ No newline at end of file
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-exam [...]
similarity index 50%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/resources/logback.xml
index 6d77c6d..154abba 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-jpa-example/src/main/resources/logback.xml
@@ -16,21 +16,19 @@
~ 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-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-readwrite-splitting-example</artifactId>
- <name>${project.artifactId}</name>
+<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>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
- </modules>
-</project>
+ <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-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis- [...]
similarity index 72%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/pom.xml
index 6d77c6d..a1bfdd9 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/pom.xml
@@ -20,17 +20,22 @@
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-readwrite-splitting-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-readwrite-splitting-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-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-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/MemoryLocalReadwriteSplittingSpringbootStarterMybatisExample.java b/examples/shardingsphere-sample/sha [...]
new file mode 100644
index 0000000..b2138b4
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/MemoryLocalReadwriteSplittingSpringbootStarterMybatisExample.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.readwrite.splitting.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.readwrite.splitting.springboot.starter.mybatis.repository")
+@SpringBootApplication
+public class MemoryLocalReadwriteSplittingSpringbootStarterMybatisExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalReadwriteSplittingSpringbootStarterMybatisExample.class, args)) {
+ MemoryLocalReadwriteSplittingSpringbootStarterMybatisExampleService exampleService = applicationContext.getBean(MemoryLocalReadwriteSplittingSpringbootStarterMybatisExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/ [...]
similarity index 83%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/MemoryLocalReadwriteSplittingSpringbootStarterMybatisExampleService.java
index ec420c8..c1c364b 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/ExampleService.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/MemoryLocalReadwriteSplittingSpringbootStarterMybatisExampleService.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')};
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository.OrderItemRepository;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository.OrderRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -28,12 +28,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
@Service
-public final class ${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService {
+public final class MemoryLocalReadwriteSplittingSpringbootStarterMybatisExampleService {
@Resource
private OrderRepository orderRepository;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/entity/Order.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memo [...]
new file mode 100644
index 0000000..7ac17cc
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/entity/Order.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity;
+
+import java.io.Serializable;
+
+public class Order implements Serializable {
+
+ private static final long serialVersionUID = 8306802022239174861L;
+
+ private long orderId;
+
+ private int userId;
+
+ private long addressId;
+
+ private String status;
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public long getAddressId() {
+ return addressId;
+ }
+
+ public void setAddressId(final long addressId) {
+ this.addressId = addressId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_id: %s, user_id: %s, address_id: %s, status: %s", orderId, userId, addressId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/entity/OrderItem.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc- [...]
new file mode 100644
index 0000000..a5d4b24
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/entity/OrderItem.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity;
+
+import java.io.Serializable;
+
+public class OrderItem implements Serializable {
+
+ private static final long serialVersionUID = 1332162822494069342L;
+
+ private long orderItemId;
+
+ private long orderId;
+
+ private int userId;
+
+ private String status;
+
+ public long getOrderItemId() {
+ return orderItemId;
+ }
+
+ public void setOrderItemId(final long orderItemId) {
+ this.orderItemId = orderItemId;
+ }
+
+ public long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(final long orderId) {
+ this.orderId = orderId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("order_item_id:%s, order_id: %s, user_id: %s, status: %s", orderItemId, orderId, userId, status);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring [...]
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/repository/OrderItemRepository.java
index 946298e..537bac9 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderItemRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/repository/OrderItemRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.OrderItem;
import java.util.List;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot [...]
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/repository/OrderRepository.java
index ad58a50..271aac8 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mybatis/OrderRepository.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/springboot/starter/mybatis/repository/OrderRepository.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository;
+package org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository;
import org.apache.ibatis.annotations.Mapper;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.Order;
import java.util.List;
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc [...]
new file mode 100644
index 0000000..74e1d48
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/application.properties
@@ -0,0 +1,45 @@
+#
+# 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.
+#
+
+mybatis.mapper-locations=classpath*:mappers/*Mapper.xml
+
+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
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
+
+spring.shardingsphere.datasource.ds-2.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-2.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-2.username=root
+spring.shardingsphere.datasource.ds-2.password=root
+
+spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-source-name=ds-0
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=ds-1,ds-2
+spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.load-balancer-name=round_robin
\ No newline at end of file
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis- [...]
similarity index 50%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/logback.xml
index 6d77c6d..154abba 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/logback.xml
@@ -16,21 +16,19 @@
~ 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-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-readwrite-splitting-example</artifactId>
- <name>${project.artifactId}</name>
+<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>
- <modules>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-readwrite-splitting-spring-namespace-jdbc-example</module>
- </modules>
-</project>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
index d901a06..afdb296 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderItemMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderItemRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.OrderItem">
+<mapper namespace="org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository.OrderItemRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.OrderItem">
<result column="order_item_id" property="orderItemId" jdbcType="INTEGER"/>
<result column="order_id" property="orderId" jdbcType="INTEGER"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
@@ -38,11 +38,11 @@
</update>
<insert id="insert" useGeneratedKeys="true" keyProperty="orderItemId">
- INSERT INTO t_order_item (order_id, user_id, status) VALUES (${r"#{orderId,jdbcType=INTEGER}"}, ${r"#{userId,jdbcType=INTEGER}"}, ${r"#{status,jdbcType=VARCHAR}"});
+ INSERT INTO t_order_item (order_id, user_id, status) VALUES (#{orderId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR});
</insert>
<delete id="delete">
- DELETE FROM t_order_item WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+ DELETE FROM t_order_item WHERE order_id = #{orderId,jdbcType=INTEGER};
</delete>
<select id="selectAll" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderMapper.xml
similarity index 84%
copy from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderMapper.xml
index b089fcc..a9064d0 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-springboot-starter-mybatis-example/src/main/resources/mappers/OrderMapper.xml
@@ -17,8 +17,8 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.repository.OrderRepository">
- <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.${feature}.${framework?replace('-', '.')}.entity.Order">
+<mapper namespace="org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.repository.OrderRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.readwrite.splitting.springboot.starter.mybatis.entity.Order">
<result column="order_id" property="orderId" jdbcType="BIGINT"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
<result column="address_id" property="addressId" jdbcType="BIGINT"/>
@@ -38,11 +38,11 @@
</update>
<insert id="insert" useGeneratedKeys="true" keyProperty="orderId">
- INSERT INTO t_order (user_id, address_id, status) VALUES (${r"#{userId,jdbcType=INTEGER}"}, ${r"#{addressId,jdbcType=BIGINT}"}, ${r"#{status,jdbcType=VARCHAR}"});
+ INSERT INTO t_order (user_id, address_id, status) VALUES (#{userId,jdbcType=INTEGER}, #{addressId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR});
</insert>
<delete id="delete">
- DELETE FROM t_order WHERE order_id = ${r"#{orderId,jdbcType=INTEGER}"};
+ DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER};
</delete>
<select id="selectAll" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-l [...]
index 8a31cf6..d38a98a 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-sharding-example/shardingsphere-jdbc-memory-local-sharding-springboot-starter-jdbc-example/pom.xml
@@ -30,11 +30,6 @@
<dependencies>
<dependency>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>example-raw-jdbc</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.2.0.RELEASE</version>