修复同一个Entity类被多个source源分表分库操作时判断表是否已建有误的bug
This commit is contained in:
@@ -74,12 +74,13 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
|
||||
synchronized (info.tables) {
|
||||
final String oldTable = info.table;
|
||||
final String newTable = info.getTable(entitys[0]);
|
||||
if (!info.tables.contains(newTable)) {
|
||||
final String catalog = conn.getCatalog();
|
||||
if (!info.tables.contains(catalog + '.' + newTable)) {
|
||||
try {
|
||||
Statement st = conn.createStatement();
|
||||
st.execute(info.tablecopySQL.replace("${newtable}", newTable).replace("${oldtable}", oldTable));
|
||||
st.close();
|
||||
info.tables.add(newTable);
|
||||
info.tables.add(catalog + '.' + newTable);
|
||||
} catch (SQLException sqle) { //多进程并发时可能会出现重复建表
|
||||
if (newTable.indexOf('.') > 0 && info.isTableNotExist(se)) {
|
||||
Statement st;
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class EntityInfo<T> {
|
||||
//用于复制表结构使用
|
||||
final String tablecopySQL;
|
||||
|
||||
//用于存在table_20160202类似这种分布式表
|
||||
//用于存在database.table_20160202类似这种分布式表
|
||||
final Set<String> tables = new HashSet<>();
|
||||
|
||||
//分表 策略
|
||||
|
||||
Reference in New Issue
Block a user