- Notifications
You must be signed in to change notification settings - Fork 59
15、同库分表使用指南
Bee edited this page Aug 15, 2020 · 1 revision
使用场景:
在一个DB中,随着数据量不断增长,需要将老的数据移到历史表中。
如,订单表orders,将5月,6月数据移到 orders_202005,orders_202006,结构与表orders一样。
如何用同一javabean,同时映射多个数据表?
API如何设计才能使用更加方便?
使用方法:
在实体类使用@Table,在操作DB时使用Suid的setDynamicParameter方法对动态参数进行赋值.
使用例子:
Suid suid=BeeFactory.getHoneyFactory().getSuid(); // @Table("Orders_${month}") // public class Orders Orders orders=new Orders(); suid.setDynamicParameter("month", "202007").select(orders); // @Entity("LeafAlloc${version}") LeafAlloc leafAlloc=new LeafAlloc(); List<LeafAlloc> list1=suid.setDynamicParameter("version", "2").select(leafAlloc); suid.setDynamicParameter("version", "2"); List<LeafAlloc> list2=suid.select(leafAlloc); Logger.info(list1.size()); Logger.info(list2.size());