Closed toby1024 closed 5 years ago
You must use HintManager
If you wanna use HintShardingAlgorithm
. Hint-example is an example for hint, maybe you should look at it first.
You must use
HintManager
If you wanna useHintShardingAlgorithm
. Hint-example is an example for hint, maybe you should look at it first.
Yes,I was read the example, it's for jdbc. Now I want to use it in mybatis, and I don't konw how to mixin the HintManager into mybatis.
HintManager
can work with myabtis too. You can call HintManager
before call mybatis mapper like this.
// call HintManager's method.
HintManager.getInstance().addTableShardingValue("t_order", 1L);
// call maybtis method.
orderMapper.selectById(id);
HintManager
can work with myabtis too. You can callHintManager
before call mybatis mapper like this.// call HintManager's method. HintManager.getInstance().addTableShardingValue("t_order", 1L); // call maybtis method. orderMapper.selectById(id);
Thanks
sharding-jdbc version: 4.0.0-RC2 springboot version: 2.1.6 mybatis version: 3.5.2 mybatis springstarter: 2.1.0 DB: mysql
I want sharding my table with a column which type is datetime, and I try code MyShardingAlgorithm implements HintShardingAlgorithm
and config in application.yml
but it looks like not worked. when I insert into table one recode , it will insert into all tables, also by query. please show me what I mistake. I find example with jdbc in github, but I don't know how to use in mybatis, has example show how to use by mybatis? thanks.