aligaduo112358 opened a new issue, #24640:
URL: https://github.com/apache/shardingsphere/issues/24640

   version:
   org.apache.shardingsphere
   sharding-jdbc-spring-boot-starter
   5.2.1
   
   application.yml
   ```yml
   spring:
     shardingsphere:
       datasource:
         names: db0
         db0:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: 
jdbc:mysql://xxx.xxx.xxx.xxx:3306/db?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
           username: root
           password: 123456
           data-source-properties:
             useLocalSessionState: false
       props:
         sql-show: true
       rules:
         bindingTables:
           - t_order,t_order_item
         sharding:
           tables:
             t_order:
               actual-data-nodes: db0.t_order_$->{[${stores}]}
             t_order_item:
               actual-data-nodes: db0.t_order_item_$->{[${stores}]}
   
           sharding-algorithms:
             table-tenant:
               type: table-tenant
               props:
                 strategy: HINT
                 algorithmClassName: 
com.xxx.server.domain.base.shardingjdbc.TableHintShardingAlgorithm
   
           defaultTableStrategy:
             hint:
               sharding-algorithm-name: table-tenant
           auditors:
             shardingKeyAudit:
               type: DML_SHARDING_CONDITIONS
   ```
   store.yml
   ```yml
   stores: "'1113','1000','5225'"
   ```
   
   TableHintShardingAlgorithm.java
   ```java
   public class TableHintShardingAlgorithm implements 
HintShardingAlgorithm<String> {
   
       @Override
       public Collection<String> doSharding(Collection<String> collection, 
HintShardingValue<String> hintShardingValue) {
           Collection<String> hintShardingValues = 
hintShardingValue.getValues();
           Collection<String> result = new ArrayList<>();
           for (String key : hintShardingValues) {
               result.add(hintShardingValue.getLogicTableName() + "_" + key);
           }
           return result;
       }
   
       @Override
       public Properties getProps() {
           return null;
       }
   
   
   
       @Override
       public String getType() {
           return "table-tenant";
       }
   
       @Override
       public void init(Properties properties) {
           // Do nothing
       }
   }
   ```
   
   Logic SQL:
   ```sql
   select order.* from t_order order,t_order_item item where item.order_id = 
order.order_id and item.product_code='1111111';
   ```
   
   I hope to get the following results:
   Actual SQL:
   ```sql
   select order.* from t_order_1113 order,t_order_item_1113 item where 
item.order_id = order.order_id and item.product_code='1111111' 
   select order.* from t_order_1000 order,t_order_item_1000 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_5225 order,t_order_item_5225 item where 
item.order_id = order.order_id and item.product_code='1111111';
   ```
   but, I got this
   ```sql
   select order.* from t_order_1113 order,t_order_item_1113 item where 
item.order_id = order.order_id and item.product_code='1111111' 
   select order.* from t_order_1113 order,t_order_item_1000 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_1113 order,t_order_item_5225 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_1000 order,t_order_item_1113 item where 
item.order_id = order.order_id and item.product_code='1111111' 
   select order.* from t_order_1000 order,t_order_item_1000 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_1000 order,t_order_item_5225 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_5225 order,t_order_item_1113 item where 
item.order_id = order.order_id and item.product_code='1111111' 
   select order.* from t_order_5225 order,t_order_item_1000 item where 
item.order_id = order.order_id and item.product_code='1111111';
   select order.* from t_order_5225 order,t_order_item_5225 item where 
item.order_id = order.order_id and item.product_code='1111111';
   ```
   
   I can't find the detailed description of the bindingTables. Can I get help?
   
   How should I configure it to achieve the desired effect?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to