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

[shardingsphere] branch master updated: Add default sharding column example (#12966)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 fb21693  Add default sharding column example (#12966)
fb21693 is described below

commit fb2169370aa1fa02e2cc4ed93aec6071a6fdabe2
Author: tuichenchuxin <86...@users.noreply.github.com>
AuthorDate: Sat Oct 9 19:34:01 2021 +0800

    Add default sharding column example (#12966)
    
    * add default sharding column example
    
    * add default sharding column example
    
    * add default sharding column example
    
    * add default sharding column example
    
    * add default sharding column example
---
 .../example/core/api/entity/Account.java           |  60 +++++++++++
 .../core/api/repository/AccountRepository.java     |  23 +++++
 .../jdbc/repository/AccountRepositoryImpl.java     | 115 +++++++++++++++++++++
 .../core/jdbc/service/AccountServiceImpl.java      | 103 ++++++++++++++++++
 .../example/core/jpa/entity/AccountEntity.java     |  54 ++++++++++
 .../core/jpa/repository/AccountRepositoryImpl.java |  70 +++++++++++++
 .../core/jpa/service/AccountServiceImpl.java       |  92 +++++++++++++++++
 .../jdbc/ShardingRawYamlConfigurationExample.java  |   9 +-
 .../ShardingRawYamlRangeConfigurationExample.java  |   9 +-
 .../resources/META-INF/sharding-auto-tables.yaml   |  10 +-
 .../META-INF/sharding-databases-range.yaml         |   7 +-
 .../META-INF/sharding-databases-tables-range.yaml  |   9 ++
 .../META-INF/sharding-databases-tables.yaml        |  14 ++-
 .../resources/META-INF/sharding-databases.yaml     |   5 +
 .../resources/META-INF/sharding-tables-range.yaml  |   9 ++
 .../main/resources/META-INF/sharding-tables.yaml   |  15 ++-
 ...pplication-sharding-databases-tables.properties |  10 ++
 .../application-sharding-databases.properties      |   5 +
 .../application-sharding-tables.properties         |  10 ++
 .../application-sharding-databases-tables.xml      |  13 ++-
 .../META-INF/application-sharding-databases.xml    |   2 +
 .../META-INF/application-sharding-tables.xml       |  15 ++-
 22 files changed, 640 insertions(+), 19 deletions(-)

diff --git a/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/entity/Account.java b/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/entity/Account.java
new file mode 100644
index 0000000..70bc19a
--- /dev/null
+++ b/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/entity/Account.java
@@ -0,0 +1,60 @@
+/*
+ * 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.core.api.entity;
+
+import java.io.Serializable;
+
+public class Account implements Serializable {
+    
+    private static final long serialVersionUID = -5889545274302226912L;
+    
+    private long accountId;
+    
+    private int userId;
+    
+    private String status;
+    
+    public long getAccountId() {
+        return accountId;
+    }
+    
+    public void setAccountId(final long accountId) {
+        this.accountId = accountId;
+    }
+    
+    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("account_id: %s, user_id: %s, status: %s", accountId, userId, status);
+    }
+}
diff --git a/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/repository/AccountRepository.java b/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/repository/AccountRepository.java
new file mode 100644
index 0000000..3096491
--- /dev/null
+++ b/examples/example-core/example-api/src/main/java/org/apache/shardingsphere/example/core/api/repository/AccountRepository.java
@@ -0,0 +1,23 @@
+/*
+ * 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.core.api.repository;
+
+import org.apache.shardingsphere.example.core.api.entity.Account;
+
+public interface AccountRepository extends CommonRepository<Account, Long> {
+}
diff --git a/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/repository/AccountRepositoryImpl.java b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/repository/AccountRepositoryImpl.java
new file mode 100644
index 0000000..563741f
--- /dev/null
+++ b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/repository/AccountRepositoryImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.core.jdbc.repository;
+
+import org.apache.shardingsphere.example.core.api.entity.Account;
+import org.apache.shardingsphere.example.core.api.repository.AccountRepository;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AccountRepositoryImpl implements AccountRepository {
+    
+    private final DataSource dataSource;
+    
+    public AccountRepositoryImpl(final DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+    
+    @Override
+    public void createTableIfNotExists() throws SQLException {
+        String sql = "CREATE TABLE IF NOT EXISTS t_account (account_id BIGINT NOT NULL AUTO_INCREMENT, user_id INT NOT NULL, status VARCHAR(50), PRIMARY KEY (account_id))";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    @Override
+    public void dropTable() throws SQLException {
+        String sql = "DROP TABLE t_account";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    @Override
+    public void truncateTable() throws SQLException {
+        String sql = "TRUNCATE TABLE t_account";
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement()) {
+            statement.executeUpdate(sql);
+        }
+    }
+    
+    @Override
+    public Long insert(final Account account) throws SQLException {
+        String sql = "INSERT INTO t_account (user_id, status) VALUES (?, ?)";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+            preparedStatement.setInt(1, account.getUserId());
+            preparedStatement.setString(2, account.getStatus());
+            preparedStatement.executeUpdate();
+            try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
+                if (resultSet.next()) {
+                    account.setAccountId(resultSet.getLong(1));
+                }
+            }
+        }
+        return account.getAccountId();
+    }
+    
+    @Override
+    public void delete(final Long accountId) throws SQLException {
+        String sql = "DELETE FROM t_account WHERE account_id=?";
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+            preparedStatement.setLong(1, accountId);
+            preparedStatement.executeUpdate();
+        }
+    }
+    
+    @Override
+    public List<Account> selectAll() throws SQLException {
+        String sql = "SELECT * FROM t_account";
+        return getAccounts(sql);
+    }
+    
+    protected List<Account> getAccounts(final String sql) throws SQLException {
+        List<Account> result = new LinkedList<>();
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = connection.prepareStatement(sql);
+             ResultSet resultSet = preparedStatement.executeQuery()) {
+            while (resultSet.next()) {
+                Account account = new Account();
+                account.setAccountId(resultSet.getLong(1));
+                account.setUserId(resultSet.getInt(2));
+                account.setStatus(resultSet.getString(3));
+                result.add(account);
+            }
+        }
+        return result;
+    }
+}
diff --git a/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/AccountServiceImpl.java b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/AccountServiceImpl.java
new file mode 100644
index 0000000..b862737
--- /dev/null
+++ b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/AccountServiceImpl.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.core.jdbc.service;
+
+import org.apache.shardingsphere.example.core.api.entity.Account;
+import org.apache.shardingsphere.example.core.api.repository.AccountRepository;
+import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.apache.shardingsphere.example.core.jdbc.repository.AccountRepositoryImpl;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public final class AccountServiceImpl implements ExampleService {
+    
+    private final AccountRepository accountRepository;
+    
+    public AccountServiceImpl(final DataSource dataSource) {
+        accountRepository = new AccountRepositoryImpl(dataSource);
+    }
+    
+    public AccountServiceImpl(final AccountRepository accountRepository) {
+        this.accountRepository = accountRepository;
+    }
+    
+    @Override
+    public void initEnvironment() throws SQLException {
+        accountRepository.createTableIfNotExists();
+        accountRepository.truncateTable();
+    }
+    
+    @Override
+    public void cleanEnvironment() throws SQLException {
+        accountRepository.dropTable();
+    }
+    
+    @Override
+    public void processSuccess() throws SQLException {
+        System.out.println("-------------- Process Success Begin ---------------");
+        List<Long> accountIds = insertData();
+        printData();
+        deleteData(accountIds);
+        printData();
+        System.out.println("-------------- Process Success Finish --------------");
+    }
+    
+    @Override
+    public 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++) {
+            Account account = insertAccounts(i);
+            result.add(account.getAccountId());
+        }
+        return result;
+    }
+    
+    private Account insertAccounts(final int i) throws SQLException {
+        Account account = new Account();
+        account.setUserId(i);
+        account.setStatus("INSERT_TEST");
+        accountRepository.insert(account);
+        return account;
+    }
+    
+    private void deleteData(final List<Long> accountIds) throws SQLException {
+        System.out.println("---------------------------- Delete Data ----------------------------");
+        for (Long each : accountIds) {
+            accountRepository.delete(each);
+        }
+    }
+    
+    @Override
+    public void printData() throws SQLException {
+        System.out.println("---------------------------- Print Account Data -----------------------");
+        for (Object each : accountRepository.selectAll()) {
+            System.out.println(each);
+        }
+    }
+}
diff --git a/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/entity/AccountEntity.java b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/entity/AccountEntity.java
new file mode 100644
index 0000000..80d88f5
--- /dev/null
+++ b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/entity/AccountEntity.java
@@ -0,0 +1,54 @@
+/*
+ * 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.core.jpa.entity;
+
+import org.apache.shardingsphere.example.core.api.entity.Account;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "t_account")
+public final class AccountEntity extends Account {
+    
+    private static final long serialVersionUID = -4004643361026020655L;
+    
+    @Id
+    @Column(name = "account_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Override
+    public long getAccountId() {
+        return super.getAccountId();
+    }
+    
+    @Column(name = "user_id")
+    @Override
+    public int getUserId() {
+        return super.getUserId();
+    }
+    
+    @Column(name = "status")
+    @Override
+    public String getStatus() {
+        return super.getStatus();
+    }
+}
diff --git a/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/repository/AccountRepositoryImpl.java b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/repository/AccountRepositoryImpl.java
new file mode 100644
index 0000000..c5445f3
--- /dev/null
+++ b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/repository/AccountRepositoryImpl.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.core.jpa.repository;
+
+import org.apache.shardingsphere.example.core.api.entity.Account;
+import org.apache.shardingsphere.example.core.api.repository.AccountRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import javax.transaction.Transactional;
+import java.util.List;
+
+@Repository
+@Transactional
+public class AccountRepositoryImpl implements AccountRepository {
+    
+    @PersistenceContext
+    private EntityManager entityManager;
+    
+    @Override
+    public void createTableIfNotExists() {
+        throw new UnsupportedOperationException("createTableIfNotExists for JPA");
+    }
+    
+    @Override
+    public void truncateTable() {
+        throw new UnsupportedOperationException("truncateTable for JPA");
+    }
+    
+    @Override
+    public void dropTable() {
+        throw new UnsupportedOperationException("dropTable for JPA");
+    }
+    
+    @Override
+    public Long insert(final Account account) {
+        entityManager.persist(account);
+        return account.getAccountId();
+    }
+    
+    @Override
+    public void delete(final Long accountId) {
+        Query query = entityManager.createQuery("DELETE FROM AccountEntity o WHERE o.accountId = ?1");
+        query.setParameter(1, accountId);
+        query.executeUpdate();
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<Account> selectAll() {
+        return (List<Account>) entityManager.createQuery("SELECT o FROM AccountEntity o").getResultList();
+    }
+}
diff --git a/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/service/AccountServiceImpl.java b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/service/AccountServiceImpl.java
new file mode 100644
index 0000000..4787104
--- /dev/null
+++ b/examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/service/AccountServiceImpl.java
@@ -0,0 +1,92 @@
+/*
+ * 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.core.jpa.service;
+
+import org.apache.shardingsphere.example.core.api.repository.AccountRepository;
+import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.apache.shardingsphere.example.core.jpa.entity.AccountEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class AccountServiceImpl implements ExampleService {
+    
+    @Resource
+    private AccountRepository accountRepository;
+    
+    @Override
+    public void initEnvironment() throws SQLException {
+    }
+    
+    @Override
+    public void cleanEnvironment() {
+    }
+    
+    @Override
+    @Transactional
+    public void processSuccess() throws SQLException {
+        System.out.println("-------------- Process Success Begin ---------------");
+        List<Long> accountIds = insertData();
+        printData();
+        deleteData(accountIds);
+        printData();
+        System.out.println("-------------- Process Success Finish --------------");
+    }
+    
+    @Override
+    @Transactional
+    public 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++) {
+            AccountEntity account = new AccountEntity();
+            account.setUserId(i);
+            account.setStatus("INSERT_TEST_JPA");
+            accountRepository.insert(account);
+            result.add(account.getAccountId());
+        }
+        return result;
+    }
+    
+    private void deleteData(final List<Long> accountIds) throws SQLException {
+        System.out.println("---------------------------- Delete Data ----------------------------");
+        for (Long each : accountIds) {
+            accountRepository.delete(each);
+        }
+    }
+    
+    @Override
+    public void printData() throws SQLException {
+        System.out.println("---------------------------- Print Account Data -----------------------");
+        for (Object each : accountRepository.selectAll()) {
+            System.out.println(each);
+        }
+    }
+}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlConfigurationExample.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlConfigurationExample.java
index 8681a78..54f43f8 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlConfigurationExample.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlConfigurationExample.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.example.sharding.raw.jdbc;
 
 import org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate;
-import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.apache.shardingsphere.example.core.jdbc.service.AccountServiceImpl;
 import org.apache.shardingsphere.example.core.jdbc.service.OrderServiceImpl;
 import org.apache.shardingsphere.example.sharding.raw.jdbc.factory.YamlDataSourceFactory;
 import org.apache.shardingsphere.example.type.ShardingType;
@@ -41,10 +41,7 @@ public final class ShardingRawYamlConfigurationExample {
     
     public static void main(final String[] args) throws SQLException, IOException {
         DataSource dataSource = YamlDataSourceFactory.newInstance(shardingType);
-        ExampleExecuteTemplate.run(getExampleService(dataSource));
-    }
-    
-    private static ExampleService getExampleService(final DataSource dataSource) {
-        return new OrderServiceImpl(dataSource);
+        ExampleExecuteTemplate.run(new OrderServiceImpl(dataSource));
+        ExampleExecuteTemplate.run(new AccountServiceImpl(dataSource));
     }
 }
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlRangeConfigurationExample.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlRangeConfigurationExample.java
index c7fba07..02faec6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlRangeConfigurationExample.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/ShardingRawYamlRangeConfigurationExample.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.example.sharding.raw.jdbc;
 
 import org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate;
-import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.apache.shardingsphere.example.core.jdbc.service.AccountServiceImpl;
 import org.apache.shardingsphere.example.core.jdbc.service.OrderServiceImpl;
 import org.apache.shardingsphere.example.sharding.raw.jdbc.factory.YamlRangeDataSourceFactory;
 import org.apache.shardingsphere.example.type.ShardingType;
@@ -40,10 +40,7 @@ public final class ShardingRawYamlRangeConfigurationExample {
     
     public static void main(final String[] args) throws SQLException, IOException {
         DataSource dataSource = YamlRangeDataSourceFactory.newInstance(shardingType);
-        ExampleExecuteTemplate.run(getExampleService(dataSource));
-    }
-    
-    private static ExampleService getExampleService(final DataSource dataSource) {
-        return new OrderServiceImpl(dataSource);
+        ExampleExecuteTemplate.run(new OrderServiceImpl(dataSource));
+        ExampleExecuteTemplate.run(new AccountServiceImpl(dataSource));
     }
 }
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-auto-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-auto-tables.yaml
index d7c957f..e884362 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-auto-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-auto-tables.yaml
@@ -50,7 +50,15 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
-  
+    t_account:
+      actualDataSources: ds_0,ds_1
+      shardingStrategy:
+        standard:
+          shardingAlgorithmName: auto_mod
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
+  defaultShardingColumn: account_id
   shardingAlgorithms:
     auto_mod:
       type: MOD
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
index 86ea261..1df9b09 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
@@ -47,16 +47,21 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds_${0..1}.t_account
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
     - t_address
   defaultDatabaseStrategy:
     standard:
-      shardingColumn: user_id
       shardingAlgorithmName: standard_test_db
   defaultTableStrategy:
     none:
+  defaultShardingColumn: user_id
   
   shardingAlgorithms:
     standard_test_db:
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml
index 56b4143..da71775 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml
@@ -50,6 +50,15 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds_${0..1}.t_account_${0..1}
+      tableStrategy:
+        standard:
+          shardingAlgorithmName: standard_test_tbl
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
+  defaultShardingColumn: account_id
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
index 15d95c0..55178ad 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
@@ -50,6 +50,15 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds_${0..1}.t_account_${0..1}
+      tableStrategy:
+        standard:
+          shardingAlgorithmName: t_account_inline
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
+  defaultShardingColumn: account_id
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
@@ -74,7 +83,10 @@ rules:
       type: INLINE
       props:
         algorithm-expression: t_order_item_${order_id % 2}
-  
+    t_account_inline:
+      type: INLINE
+      props:
+        algorithm-expression: t_account_${account_id % 2}
   keyGenerators:
     snowflake:
       type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
index 1774662..fb0f202 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
@@ -48,6 +48,11 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds_${0..1}.t_account
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml
index df9c7c4..7240996 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml
@@ -44,6 +44,15 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds.t_account_${0..1}
+      tableStrategy:
+        standard:
+          shardingAlgorithmName: standard_test_tbl
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
+  defaultShardingColumn: account_id
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml
index e76afe9..543586f 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml
@@ -44,6 +44,15 @@ rules:
       keyGenerateStrategy:
         column: order_item_id
         keyGeneratorName: snowflake
+    t_account:
+      actualDataNodes: ds.t_account_${0..1}
+      tableStrategy:
+        standard:
+          shardingAlgorithmName: t_account_inline
+      keyGenerateStrategy:
+        column: account_id
+        keyGeneratorName: snowflake
+  defaultShardingColumn: account_id
   bindingTables:
     - t_order,t_order_item
   broadcastTables:
@@ -58,7 +67,11 @@ rules:
       type: INLINE
       props:
         algorithm-expression: t_order_item_${order_id % 2}
-  
+    t_account_inline:
+      type: INLINE
+      props:
+        algorithm-expression: t_account_${account_id % 2}
+
   keyGenerators:
     snowflake:
       type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
index 71cf790..57e5f6a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
@@ -50,12 +50,22 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard
 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.tables.t_account.actual-data-nodes=ds-$->{0..1}.t_account_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-inline
+
+spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
+spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.default-sharding-column=account_id
+
 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.sharding-algorithms.t-account-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.props.algorithm-expression=t_account_$->{account_id % 2}
 
 spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
 spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
index 10fc538..044d6af 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
@@ -44,6 +44,11 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$-
 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.tables.t_account.actual-data-nodes=ds-$->{0..1}.t_account
+
+spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
+spring.shardingsphere.rules.sharding.tables.t_account.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}
 
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
index 67333bf..74d044b 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
@@ -38,6 +38,14 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard
 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.tables.t_account.actual-data-nodes=ds.t_account_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-inline
+
+spring.shardingsphere.rules.sharding.default-sharding-column=account_id
+
+spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
+spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
+
 spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
 spring.shardingsphere.rules.sharding.broadcast-tables=t_address
 
@@ -45,6 +53,8 @@ spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INL
 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.sharding-algorithms.t-account-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.props.algorithm-expression=t_account_$->{account_id % 2}
 
 spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
 spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
index 7fe7692..d4bc491 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -82,7 +82,16 @@
             <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
         </props>
     </sharding:sharding-algorithm>
+
+    <sharding:sharding-algorithm id="accountTableAlgorithm" type="INLINE">
+        <props>
+            <prop key="algorithm-expression">t_account_${account_id % 2}</prop>
+        </props>
+    </sharding:sharding-algorithm>
+
     <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
+
+    <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
     
     <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="INLINE">
         <props>
@@ -99,11 +108,13 @@
     
     <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
     <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
+    <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
     
-    <sharding:rule id="shardingRule">
+    <sharding:rule id="shardingRule" default-sharding-column="account_id">
         <sharding:table-rules>
             <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
             <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
+            <sharding:table-rule logic-table="t_account" actual-data-nodes="demo_ds_${0..1}.t_account_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
         </sharding:table-rules>
         <sharding:binding-table-rules>
             <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
index 9bb62d3..5851ab0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -82,12 +82,14 @@
     </sharding:key-generate-algorithm>
     
     <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
+    <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
     <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
     
     <sharding:rule id="shardingRule">
         <sharding:table-rules>
             <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
             <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" />
+            <sharding:table-rule logic-table="t_account" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="accountKeyGenerator" />
         </sharding:table-rules>
         <sharding:binding-table-rules>
             <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
index 3719997..27f1ade 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -66,8 +66,17 @@
             <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
         </props>
     </sharding:sharding-algorithm>
+
+    <sharding:sharding-algorithm id="accountTableAlgorithm" type="INLINE">
+        <props>
+            <prop key="algorithm-expression">t_account_${account_id % 2}</prop>
+        </props>
+    </sharding:sharding-algorithm>
+
     <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-    
+
+    <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
+
     <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="INLINE">
         <props>
             <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
@@ -83,11 +92,13 @@
     
     <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
     <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
+    <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
     
-    <sharding:rule id="shardingRule">
+    <sharding:rule id="shardingRule" default-sharding-column="account_id">
         <sharding:table-rules>
             <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
             <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds.t_order_item_${0..1}" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
+            <sharding:table-rule logic-table="t_account" actual-data-nodes="demo_ds.t_account_${0..1}" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
         </sharding:table-rules>
         <sharding:binding-table-rules>
             <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>