”tbxxx" dataNode="transDN0" ruleRequired=”false”/
rule.xml
分库分表规则配置,其中columns,dbRuleList,tbRuleList里面的列名要保持大写
首先先上一个整体配置 "rule1">
TRANS_ID
#set($end=$TRANS_ID.length() - 1)##
$stringUtil.substring($TRANS_ID,$start,$end)]]>
$stringUtil.substring($TRANS_ID,$start)]]>
def map = [:];
for (int i=0; i<10; i++) {
def list = [];
for (int j=0; j<10; j++) {
list.add(i+""+j);
}
map.put(i,list);
};
return map;
]]>
其中dbRuleList 为分库规则
#set($end=$TRANS_ID.length() - 1)##
$stringUtil.substring($TRANS_ID,$start,$end)]]>
分库规则dbRuleList可以有多个dbRule,当第一个不满足时,可以用第二个,当然这个效率不好,如果有规则区分,尽量再写一个rule,
dbRule 最后的结果是表的前缀