
pers.zr.opensource.magic.dao.action.Insert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magic-dao Show documentation
Show all versions of magic-dao Show documentation
simplify to access database with java.
package pers.zr.opensource.magic.dao.action;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* Created by zhurong on 2016-4-28.
*/
public class Insert extends Action {
private Map insertFields;
public void setInsertFields(Map insertFields) {
this.insertFields = insertFields;
}
private String realTableName = null;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override
public ActionMode getActionMode() {
return ActionMode.INSERT;
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy();
TableShardHandler tableShardHandler = table.getTableShardHandler();
if(null != tableShardHandler && null != tableShardStrategy) {
String[] shardColumns = tableShardStrategy.getShardColumns();
List shardColumnList = Arrays.asList(shardColumns);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy