All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.antelopeframework.mybatis.shard.converter.InsertSqlConverter Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package com.github.antelopeframework.mybatis.shard.converter;

import java.util.Map;

import com.github.antelopeframework.mybatis.shard.ShardContext.ShardOnPair;

import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.insert.Insert;

/**
 * INSERT 语句表名替换.
 * 
 * @author yangzhi.yzh
 *
 */
class InsertSqlConverter extends AbstractSqlConverter {
	
	@Override
	protected Statement doConvert(String sqlMapperId, Statement statement, Map shardOns) {
		if (!(statement instanceof Insert)) {
			throw new IllegalArgumentException("The argument statement must is instance of Insert.");
		}
		
		Insert insert = (Insert) statement;

		String tableName = insert.getTable().getName();
		insert.getTable().setName(convertTableName(sqlMapperId, tableName, shardOns));

		return insert;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy