
pers.zr.opensource.magic.dao.action.Update 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 java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by zhurong on 2016-4-28.
*/
public class Update extends ConditionalAction {
private Map updateFields;
public void setUpdateFields(Map updateFields) {
this.updateFields = updateFields;
}
@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.UPDATE;
}
private void parse() {
if(CollectionUtils.isEmpty(updateFields)) {
throw new RuntimeException("update fields can not be empty!");
}
StringBuilder sqlBuilder = new StringBuilder("UPDATE ").append(getRealTableName()).append(" SET ");
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy