@Bean
public shardingsphere.demo.entity.Order order(){
shardingsphere.demo.entity.Order order=new Order();
order.setId(new Random(100).nextLong());
order.setOrderId(101);
order.setUserId(6);
orderMapper.insert(order);
order.setId(new Random(100).nextLong());
order.setOrderId(102);
order.setUserId(5);
orderMapper.insert(order);
HintManager.getInstance().setMasterRouteOnly(); //-----------------------------------核心 跟pagehelper 分页插件类似 只作用于最近的一条查询语句,
List<Order> byUserId = orderMapper.findByUserId(5);
HintManager.getInstance().setMasterRouteOnly();
List<Order> b2 = orderMapper.findByUserId(6);
List<Long> longs=new ArrayList<>();
longs.add(5L);
longs.add(6L);
HintManager.get
shardingjdbc 强制路由走主库查询实时数据 避免主从同步数据延迟
最新推荐文章于 2024-06-20 10:46:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)