com.github.antelopeframework.mybatis.shard.converter.UpdateSqlConverter Maven / Gradle / Ivy
package com.github.antelopeframework.mybatis.shard.converter;
import java.util.List;
import java.util.Map;
import com.github.antelopeframework.mybatis.shard.ShardContext.ShardOnPair;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.update.Update;
/**
* UPDATE 语句表名替换.
*
* @author yangzhi.yzh
*
*/
class UpdateSqlConverter extends AbstractSqlConverter {
@Override
protected Statement doConvert(String sqlMapperId, Statement statement, Map shardOns) {
if (!(statement instanceof Update)) {
throw new IllegalArgumentException("The argument statement must is instance of Update.");
}
Update update = (Update) statement;
List tables = update.getTables();
for (Table table : tables) {
String tableName = table.getName();
table.setName(convertTableName(sqlMapperId, tableName, shardOns));
}
return update;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy