com.blr19c.common.mybatisWrapper.wrapper.insert.OracleInsertWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
The blr19c-common library contains utility classes, Map/Stream implementation, sending enterprise
WeChat, IP/ip address acquisition, mybatis-plus separation implementation, and so on.
package com.blr19c.common.mybatisWrapper.wrapper.insert;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
import com.blr19c.common.mybatisWrapper.enums.SqlMethod;
import java.util.Collection;
/**
* 插入 oracle专用
*
* @author blr
*/
public interface OracleInsertWrapper extends InsertWrapper {
/**
* 新增
*
* @param modelClass 实体类class
* @param modelList 新增的数据
*/
@Override
default int insert(Class> modelClass, Collection modelList) {
String id = initMappedStatement(modelClass, Integer.class).getId();
return getSqlSessionTemplate().insert(id, toSqlForeach(modelList));
}
@Override
default AbstractWrapperMethod getWrapperMethod() {
return OracleInsertMethod.instance;
}
class OracleInsertMethod extends InsertMethod {
static OracleInsertMethod instance = new OracleInsertMethod();
@Override
protected SqlMethod sqlMethod() {
return SqlMethod.ORACLE_INSERT;
}
@Override
protected String getFieldSql(TableInfo tableInfo) {
return SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlColumnMaybeIf(getInsertPrefix()),
LEFT_BRACKET, RIGHT_BRACKET, null, COMMA);
}
@Override
protected String getValueSql(TableInfo tableInfo) {
return SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlPropertyMaybeIf(getInsertPrefix()),
LEFT_BRACKET, RIGHT_BRACKET, null, COMMA);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy