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 2020/07/21 10:47:16 UTC

[GitHub] [shardingsphere] andyhewenhui commented on issue #6385: Why do you also detect statements that do not set up a sub-table?

andyhewenhui commented on issue #6385:
URL: https://github.com/apache/shardingsphere/issues/6385#issuecomment-661782591


   <!-- 因为分库分表使用 shardingsphere 策略 ,因此Druid更加适合系统 -->
       <bean id="coinDataSource" destroy-method="close" class="com.alibaba.druid.pool.DruidDataSource">
               <property name="driverClassName" value="${jdbc.driverClassName}" />
               <property name="url" value="${jdbc.url.coin}" />
               <property name="username" value="${jdbc.username}" />
               <property name="password" value="${jdbc.password}" />
   
               <property name="initialSize" value="5" />
               <property name="maxActive" value="20" />
               <property name="maxWait" value="5000" />
               <property name="minIdle" value="5" />
               <property name="poolPreparedStatements" value="true" />
               <property name="defaultAutoCommit" value="false" />
       </bean>
   
       <bean:properties id="properties">
           <prop key="worker.id">${worker.id}</prop>
       </bean:properties>
       <sharding:key-generator id="snowCoinKeyGenerator" type="SNOWFLAKE" column="snowId" props-ref="properties" />
   
   
       <sharding:inline-strategy id="coinAccountLogTableStrategy" sharding-column="userId" algorithm-expression="coin_account_log_${userId % 10}" />
       <sharding:inline-strategy id="coinGameTableStrategy" sharding-column="userId" algorithm-expression="coin_game_log_${userId % 10}" />
       <sharding:inline-strategy id="coinShareTableStrategy" sharding-column="userId" algorithm-expression="coin_share_${userId % 10}" />
       <sharding:inline-strategy id="coinTaskLogTableStrategy" sharding-column="userId" algorithm-expression="coin_task_log_${userId % 10}" />
   
       <sharding:data-source id="shardingCoinDataSource">
           <sharding:sharding-rule data-source-names="coinDataSource">
               <sharding:table-rules>
                   <sharding:table-rule logic-table="coin_account_log" actual-data-nodes="coinDataSource.coin_account_log_${0..9}"
                                        table-strategy-ref="coinAccountLogTableStrategy" key-generator-ref="snowCoinKeyGenerator" />
                   <sharding:table-rule logic-table="coin_game_log" actual-data-nodes="coinDataSource.coin_game_log_${0..9}"
                                        table-strategy-ref="coinGameTableStrategy" key-generator-ref="snowCoinKeyGenerator" />
                   <sharding:table-rule logic-table="coin_share" actual-data-nodes="coinDataSource.coin_share_${0..9}"
                                        table-strategy-ref="coinShareTableStrategy" key-generator-ref="snowCoinKeyGenerator" />
                   <sharding:table-rule logic-table="coin_task_log" actual-data-nodes="coinDataSource.coin_task_log_${0..9}"
                                        table-strategy-ref="coinTaskLogTableStrategy" key-generator-ref="snowCoinKeyGenerator" />
               </sharding:table-rules>
           </sharding:sharding-rule>
           <sharding:props>
               <prop key="sql.show">true</prop>
           </sharding:props>
       </sharding:data-source>
   
   
   After this setting, all the SQL statements in the following mapper will be affected.
   <mappers>
           <mapper resource="biz/coin/mybatis/mappers/CoinAccountMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinAccountLogMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinTaskMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinTaskLogMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinGameLogMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinShareMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinConfigInfoMapper.xml" />
           <mapper resource="biz/coin/mybatis/mappers/CoinVIPRewardMapper.xml" />
       </mappers>


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