com.kukababy.plus.dao.UpdateImpl Maven / Gradle / Ivy
The newest version!
package com.kukababy.plus.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.script.ScriptEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import com.kukababy.plus.exception.PlusRuntimeException;
import com.kukababy.plus.pojo.SqlPo;
import com.kukababy.plus.pojo.SqlCfg;
import com.kukababy.plus.pojo.SqlVal;
/**
*
* 描述:
*
*
* @author [email protected]
* @date 2019年3月5日 下午10:53:19
*/
public class UpdateImpl extends BasePlus implements UpdateFace {
private static final Logger log = LoggerFactory.getLogger(UpdateImpl.class);
/**
* @param injectParam
*/
public UpdateImpl(SqlCfg sqlCfg, ScriptEngine engine) {
super(sqlCfg,engine);
// TODO Auto-generated constructor stub
}
@Override
public int update(Object entity) {
SqlPo sqlPo = this.getSqlPo(entity.getClass(),sqlCfg.getCamel());
SqlVal sqlVal = this.getSqlVal(sqlPo, entity);
if (sqlPo.getKey() == null || sqlVal.getKeyVal() == null) {
throw new PlusRuntimeException("没有主键或主键值为NULL");
}
String updateSql = this.getUpdateSql(sqlPo);
Object allVals[] = this.getUpdateVals(sqlPo, sqlVal);
return sqlCfg.getJdbcTemplate().update(updateSql, allVals);
}
@Override
public int updateBatch(List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy