Loading README.md +48 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ before we use docker compose, please install docker first : https://docs.docker. to clean the docker container , you could use docker rm `docker ps -a -q` (be careful) ## sharding-sphere-example module design ### project module ``` sharding-sphere-example ├── example-common Loading @@ -45,7 +47,7 @@ sharding-sphere-example │ ├── orchestration-example │ │ ├── orchestration-raw-jdbc-example │ │ ├── orchestration-spring-boot-example │ │ ├── orchestration-spring-namespace-example │ │ └── orchestration-spring-namespace-example │ ├── sharding-example │ │ ├── sharding-raw-jdbc-example │ │ ├── sharding-spring-boot-jpa-example Loading @@ -57,8 +59,51 @@ sharding-sphere-example │ └── transaction-base-saga-example ├── sharding-proxy-example │ └── sharding-proxy-boot-mybatis-example ├── src/resources │ ├── manual_schema.sql └── src/resources └── manual_schema.sql ``` ### Best practice for sharding data * sharding databases * sharding tables * sharding databases and tables * master-slave * sharding & master-slave you can get more detail from **[sharding-example](./sharding-jdbc-example/sharding-example)** ### Best practice for sharding + orchestration * local zookeeper/etcd & sharding local sharding configuration can override the configuration of zookeeper/etcd. * cloud zookeeper/etcd & sharding shardingsphere will load the sharding configuration form zookeeper/etcd directly. you can get more detail from **[orchestration-example](./sharding-jdbc-example/orchestration-example)** ### Best Practice for sharding + distribution-transaction * 2pc-xa transaction * base-saga transaction you can get more detail from **[transaction-example](./sharding-jdbc-example/transaction-example)** ### how to use hint routing we will add hint example recently. ### how to config none-sharding tables we will add none-sharding example recently. ### how to config broadcast-table we will add broadcast-table example recently. ### how to use APM with shardingsphere we will add APM example recently. ### how to encrypt & decrypt data in shardingsphere we prefer to add encrypt & decrypt example recently. ### how to use sharding-proxy with jdbc. we prefer to add a docker base example recently. example-common/repository-jpa/src/main/java/io/shardingsphere/example/common/jpa/service/JPACommonServiceImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; @Service @Transactional public class JPACommonServiceImpl implements JPACommonService { @Resource Loading @@ -47,6 +46,7 @@ public class JPACommonServiceImpl implements JPACommonService { } @Override @Transactional public void processSuccess() { System.out.println("-------------- Process Success Begin ---------------"); List<Long> orderIds = insertData(); Loading @@ -57,6 +57,7 @@ public class JPACommonServiceImpl implements JPACommonService { } @Override @Transactional public void processFailure() { System.out.println("-------------- Process Failure Begin ---------------"); insertData(); Loading example-common/repository-mybatis/src/main/java/io/shardingsphere/example/common/mybatis/service/SpringPojoServiceImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; @Service @Transactional public class SpringPojoServiceImpl implements SpringPojoService { @Resource Loading @@ -53,6 +52,7 @@ public class SpringPojoServiceImpl implements SpringPojoService { } @Override @Transactional public void processSuccess() { System.out.println("-------------- Process Success Begin ---------------"); List<Long> orderIds = insertData(); Loading @@ -63,6 +63,7 @@ public class SpringPojoServiceImpl implements SpringPojoService { } @Override @Transactional public void processFailure() { System.out.println("-------------- Process Failure Begin ---------------"); insertData(); Loading pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ <project.build.locale>zh_CN</project.build.locale> <sharding-sphere.version>4.0.0-RC1-SNAPSHOT</sharding-sphere.version> <sharding-sphere.spi.impl.version>4.0.0.M1-SNAPSHOT</sharding-sphere.spi.impl.version> <sharding-sphere.spi.impl.version>4.0.0-RC1-SNAPSHOT</sharding-sphere.spi.impl.version> <aspectjweaver.version>1.8.9</aspectjweaver.version> <spring-framework.version>4.3.20.RELEASE</spring-framework.version> Loading sharding-jdbc-example/transaction-example/transaction-2pc-xa-example/transaction-xa-spring-boot-example/src/main/java/io/shardingsphere/example/transaction/xa/spring/boot/SpringBootExample.java +1 −2 Original line number Diff line number Diff line Loading @@ -20,13 +20,12 @@ package io.shardingsphere.example.transaction.xa.spring.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; @ComponentScan({"io.shardingsphere.example"}) @EntityScan(basePackages = "io.shardingsphere.example.common.jpa.entity") @SpringBootApplication(exclude = JtaAutoConfiguration.class) @SpringBootApplication public class SpringBootExample { public static void main(final String[] args) { Loading Loading
README.md +48 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ before we use docker compose, please install docker first : https://docs.docker. to clean the docker container , you could use docker rm `docker ps -a -q` (be careful) ## sharding-sphere-example module design ### project module ``` sharding-sphere-example ├── example-common Loading @@ -45,7 +47,7 @@ sharding-sphere-example │ ├── orchestration-example │ │ ├── orchestration-raw-jdbc-example │ │ ├── orchestration-spring-boot-example │ │ ├── orchestration-spring-namespace-example │ │ └── orchestration-spring-namespace-example │ ├── sharding-example │ │ ├── sharding-raw-jdbc-example │ │ ├── sharding-spring-boot-jpa-example Loading @@ -57,8 +59,51 @@ sharding-sphere-example │ └── transaction-base-saga-example ├── sharding-proxy-example │ └── sharding-proxy-boot-mybatis-example ├── src/resources │ ├── manual_schema.sql └── src/resources └── manual_schema.sql ``` ### Best practice for sharding data * sharding databases * sharding tables * sharding databases and tables * master-slave * sharding & master-slave you can get more detail from **[sharding-example](./sharding-jdbc-example/sharding-example)** ### Best practice for sharding + orchestration * local zookeeper/etcd & sharding local sharding configuration can override the configuration of zookeeper/etcd. * cloud zookeeper/etcd & sharding shardingsphere will load the sharding configuration form zookeeper/etcd directly. you can get more detail from **[orchestration-example](./sharding-jdbc-example/orchestration-example)** ### Best Practice for sharding + distribution-transaction * 2pc-xa transaction * base-saga transaction you can get more detail from **[transaction-example](./sharding-jdbc-example/transaction-example)** ### how to use hint routing we will add hint example recently. ### how to config none-sharding tables we will add none-sharding example recently. ### how to config broadcast-table we will add broadcast-table example recently. ### how to use APM with shardingsphere we will add APM example recently. ### how to encrypt & decrypt data in shardingsphere we prefer to add encrypt & decrypt example recently. ### how to use sharding-proxy with jdbc. we prefer to add a docker base example recently.
example-common/repository-jpa/src/main/java/io/shardingsphere/example/common/jpa/service/JPACommonServiceImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; @Service @Transactional public class JPACommonServiceImpl implements JPACommonService { @Resource Loading @@ -47,6 +46,7 @@ public class JPACommonServiceImpl implements JPACommonService { } @Override @Transactional public void processSuccess() { System.out.println("-------------- Process Success Begin ---------------"); List<Long> orderIds = insertData(); Loading @@ -57,6 +57,7 @@ public class JPACommonServiceImpl implements JPACommonService { } @Override @Transactional public void processFailure() { System.out.println("-------------- Process Failure Begin ---------------"); insertData(); Loading
example-common/repository-mybatis/src/main/java/io/shardingsphere/example/common/mybatis/service/SpringPojoServiceImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; @Service @Transactional public class SpringPojoServiceImpl implements SpringPojoService { @Resource Loading @@ -53,6 +52,7 @@ public class SpringPojoServiceImpl implements SpringPojoService { } @Override @Transactional public void processSuccess() { System.out.println("-------------- Process Success Begin ---------------"); List<Long> orderIds = insertData(); Loading @@ -63,6 +63,7 @@ public class SpringPojoServiceImpl implements SpringPojoService { } @Override @Transactional public void processFailure() { System.out.println("-------------- Process Failure Begin ---------------"); insertData(); Loading
pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ <project.build.locale>zh_CN</project.build.locale> <sharding-sphere.version>4.0.0-RC1-SNAPSHOT</sharding-sphere.version> <sharding-sphere.spi.impl.version>4.0.0.M1-SNAPSHOT</sharding-sphere.spi.impl.version> <sharding-sphere.spi.impl.version>4.0.0-RC1-SNAPSHOT</sharding-sphere.spi.impl.version> <aspectjweaver.version>1.8.9</aspectjweaver.version> <spring-framework.version>4.3.20.RELEASE</spring-framework.version> Loading
sharding-jdbc-example/transaction-example/transaction-2pc-xa-example/transaction-xa-spring-boot-example/src/main/java/io/shardingsphere/example/transaction/xa/spring/boot/SpringBootExample.java +1 −2 Original line number Diff line number Diff line Loading @@ -20,13 +20,12 @@ package io.shardingsphere.example.transaction.xa.spring.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; @ComponentScan({"io.shardingsphere.example"}) @EntityScan(basePackages = "io.shardingsphere.example.common.jpa.entity") @SpringBootApplication(exclude = JtaAutoConfiguration.class) @SpringBootApplication public class SpringBootExample { public static void main(final String[] args) { Loading