You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/04/14 09:21:21 UTC

[GitHub] [shardingsphere] 726411951 opened a new issue #10086: Is there a better way to cofig sharding properties

726411951 opened a new issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086


   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   ![image](https://user-images.githubusercontent.com/32379580/114683712-d3b21d80-9d42-11eb-9c1d-8c6e71115b05.png)
   
   As the describe in  documents , if I create tables `t_order`  `t_user`   and I want to do  databases sharding .I must config like 
   
   spring.shardingsphere.rules.sharding.tables.**t_order**.database-strategy.standard.<sharding-algorithm-name>.sharding-column= # Sharding column name
   spring.shardingsphere.rules.sharding.tables.**t_order**.database-strategy.standard.<sharding-algorithm-name>.sharding-algorithm-name= # Sharding algorithm name
   spring.shardingsphere.rules.sharding.tables.**t_user**.database-strategy.standard.<sharding-algorithm-name>.sharding-column= # Sharding column name
   spring.shardingsphere.rules.sharding.tables.**t_user**.database-strategy.standard.<sharding-algorithm-name>.sharding-algorithm-name= # Sharding algorithm name
   
   if I have more tables , I should write more and more configuration for every table. 
   Is there a better way to cofig sharding properties ,if `sharding-column` and `sharding-algorithm-name` are the same.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 edited a comment on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 edited a comment on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-822906345


   > > You can consider using the `default-table-strategy` and `default-database-strategy`.
   > 
   > hi, @tristaZero ,I tried to use the `default-database-strategy` like
   > 
   > spring.shardingsphere.sharding.default-database-strategy.standard.sharding-column=sharding_code
   > spring.shardingsphere.sharding.default-database-strategy.standard.precise-algorithm-class-name=com.xx.ShardingAlgorithmConfig
   > 
   > and my test SQL statements for select ,insert
   > `select id,`name`, sharding from t_order where sharding_code= ?`
   > 
   > `insert into t_order(id, `name`, sharding_code) values (#{?,jdbcType=INTEGER}, #{?,jdbcType=VARCHAR}{?,jdbcType=VARCHAR} )`
   > 
   > but it seems like this config is invalid when the project run, the result is it access random datebase and dont use the precise-algorithm`ShardingAlgorithmConfig` class .
   > 
   > when config like
   > ![image](https://user-images.githubusercontent.com/32379580/114968352-bc8d4000-9ea8-11eb-80c9-1f243431f740.png)
   > it can access valid datebase
   > 
   > so ,what's the matter
   > and the version is 4.1.1
   > thanks
   
    I only configure `default-database-strategy` and there is no specific `database-strategy`,  but it is invalid.The two datebase `test_db0`,`test_db1` was accessed by random
   so, I don't not what happened @tristaZero  ,thanks for your reply


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-820359110


   You can consider using the `default-table-strategy` and  `default-database-strategy`.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 closed issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 closed issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-820885230


   > You can consider using the `default-table-strategy` and `default-database-strategy`.
   
   hi, @tristaZero  ,I tried to use the  `default-database-strategy` like
   
   spring.shardingsphere.sharding.default-database-strategy.standard.sharding-column=sharding_code
   spring.shardingsphere.sharding.default-database-strategy.standard.precise-algorithm-class-name=com.xx.ShardingAlgorithmConfig
   
   and my test SQL statements for select ,insert
   ` select  id, `name`, sharding from t_order where sharding_code= ?`
   
   `insert into t_order(id, `name`, sharding_code)  values (#{?,jdbcType=INTEGER}, #{?,jdbcType=VARCHAR}{?,jdbcType=VARCHAR} )`
   
   but it seems like this config is invalid when the project run, the result is it access random datebase and dont use the precise-algorithm`ShardingAlgorithmConfig` class .  
   
   when config like
   ![image](https://user-images.githubusercontent.com/32379580/114968352-bc8d4000-9ea8-11eb-80c9-1f243431f740.png)
   it can access  valid datebase 
   
   so ,what's the matter
   and the version is 4.1.1
   thanks


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-821067197


   When `default-database-stratege` exists, you did not configure `database-strategy` for specific sharding table, didn't you?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-823927494


   If your scenario is sharding, do you think [examples](https://github.com/apache/shardingsphere/blob/4.1.1/examples/sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties) can give you some hints?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-822109517


   Hi @tristaZero  
   Should I configure like 
   #default
   spring.shardingsphere.sharding.default-database-strategy.standard.sharding-column=sharding_code
   spring.shardingsphere.sharding.default-database-strategy.standard.precise-algorithm-class-name=com.xx.ShardingAlgorithmConfig
   #specific
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-column= sharding_code
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-algorithm-name= com.xx.ShardingAlgorithmConfig


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-824745968


   use the examlpes config,but `default-database-strategy` is failure and only add data in `default-data-source-name`


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-822888502


   Hi I mean once `default-database-strategy` and `t_order.database-strategy` exist,  `t_order.database-strategy`  will override  the default one. So if you want default strategy takes effect, please do not configure any specific `database-strategy` for these tables.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-822108882


   @tristaZero  should 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 closed issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 closed issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 726411951 commented on issue #10086: Is there a better way to cofig sharding properties

Posted by GitBox <gi...@apache.org>.
726411951 commented on issue #10086:
URL: https://github.com/apache/shardingsphere/issues/10086#issuecomment-822906345


   > > You can consider using the `default-table-strategy` and `default-database-strategy`.
   > 
   > hi, @tristaZero ,I tried to use the `default-database-strategy` like
   > 
   > spring.shardingsphere.sharding.default-database-strategy.standard.sharding-column=sharding_code
   > spring.shardingsphere.sharding.default-database-strategy.standard.precise-algorithm-class-name=com.xx.ShardingAlgorithmConfig
   > 
   > and my test SQL statements for select ,insert
   > `select id,`name`, sharding from t_order where sharding_code= ?`
   > 
   > `insert into t_order(id, `name`, sharding_code) values (#{?,jdbcType=INTEGER}, #{?,jdbcType=VARCHAR}{?,jdbcType=VARCHAR} )`
   > 
   > but it seems like this config is invalid when the project run, the result is it access random datebase and dont use the precise-algorithm`ShardingAlgorithmConfig` class .
   > 
   > when config like
   > ![image](https://user-images.githubusercontent.com/32379580/114968352-bc8d4000-9ea8-11eb-80c9-1f243431f740.png)
   > it can access valid datebase
   > 
   > so ,what's the matter
   > and the version is 4.1.1
   > thanks
   
    I only configure `default-database-strategy` and there is no specific `database-strategy`,  but it is invalid.The two datebase `test_db0`,`test_db1` was accessed by random


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org