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 2019/06/27 06:51:08 UTC
[GitHub] [incubator-shardingsphere] xiaotianlongxing opened a new issue
#2617: How to config the hint by spring namespace int the sharding-jdbc 3.1
version
xiaotianlongxing opened a new issue #2617: How to config the hint by spring namespace int the sharding-jdbc 3.1 version
URL: https://github.com/apache/incubator-shardingsphere/issues/2617
## How to config the hint by spring namespace int the sharding-jdbc 3.1 version
My applicationContext.xml config is useless
as follow:
```
<bean id="tableShardingAlgorithmByMonth" class="com.xxx.TableShardingAlgorithmByMonth"></bean>
<bean id="hintTestBean" class="com.xxx.ModuloHintShardingAlgorithm"></bean>
<sharding:hint-strategy id="hintStrategy" algorithm-ref="hintTestBean" ></sharding:hint-strategy>
<sharding:standard-strategy id="payOrderPreciseAlgorithm" sharding-column="create_date" precise-algorithm-ref="tableShardingAlgorithmByMonth"></sharding:standard-strategy>
<sharding:data-source id="shardingDataSource">
<sharding:sharding-rule data-source-names="dataSource">
<sharding:table-rules>
<sharding:table-rule logic-table="pay_order" table-strategy-ref="payOrderPreciseAlgorithm" />
</sharding:table-rules>
<sharding:binding-table-rules>
<sharding:binding-table-rule logic-tables="pay_order"/>
</sharding:binding-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop key="sql.show">false</prop>
</sharding:props>
</sharding:data-source>
```
The ModuloHintShardingAlgorithm.java as follow:
```
import io.shardingsphere.api.algorithm.sharding.ShardingValue;
import io.shardingsphere.api.algorithm.sharding.hint.HintShardingAlgorithm;
import java.util.Collection;
public class ModuloHintShardingAlgorithm implements HintShardingAlgorithm {
@Override
public Collection<String> doSharding(Collection<String> availableTargetNames, ShardingValue shardingValue) {
System.out.println(shardingValue.getLogicTableName());
for (String each : availableTargetNames) {
System.out.println(each);
}
return null;
}
}
```
But when querying, this function will not be called.
Is my configuration right?
I could`t find the configuration of hint spring namespace in [https://github.com/apache/incubator-shardingsphere-example](url)
----------------------------------------------------------------
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
With regards,
Apache Git Services