com.easy.query.api4j.insert.AbstractEntityInsertable Maven / Gradle / Ivy
package com.easy.query.api4j.insert;
import com.easy.query.api4j.sql.SQLColumnConfigurer;
import com.easy.query.api4j.sql.SQLColumnOnlySelector;
import com.easy.query.api4j.sql.impl.SQLColumnConfigurerImpl;
import com.easy.query.api4j.sql.impl.SQLColumnOnlySelectorImpl;
import com.easy.query.api4j.util.EasyLambdaUtil;
import com.easy.query.core.basic.api.insert.ClientInsertable;
import com.easy.query.core.basic.jdbc.parameter.ToSQLContext;
import com.easy.query.core.enums.SQLExecuteStrategyEnum;
import com.easy.query.core.expression.lambda.Property;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.sql.builder.EntityInsertExpressionBuilder;
import com.easy.query.core.expression.sql.builder.internal.ContextConfigurer;
import com.easy.query.core.expression.sql.builder.internal.EasyBehavior;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Function;
/**
* create time 2023/6/2 16:15
* 文件说明
*
* @author xuejiaming
*/
public abstract class AbstractEntityInsertable implements EntityInsertable {
private final ClientInsertable clientInsertable;
public AbstractEntityInsertable(ClientInsertable clientInsertable) {
this.clientInsertable = clientInsertable;
}
@Override
public EntityInsertable insert(T entity) {
clientInsertable.insert(entity);
return this;
}
@Override
public EntityInsertable insert(Collection entities) {
clientInsertable.insert(entities);
return this;
}
@Override
public EntityInsertExpressionBuilder getEntityInsertExpressionBuilder() {
return clientInsertable.getEntityInsertExpressionBuilder();
}
@Override
public long executeRows(boolean fillAutoIncrement) {
return clientInsertable.executeRows(fillAutoIncrement);
}
@Override
public EntityInsertable noInterceptor() {
clientInsertable.noInterceptor();
return this;
}
@Override
public EntityInsertable useInterceptor(String name) {
clientInsertable.useInterceptor(name);
return this;
}
@Override
public EntityInsertable noInterceptor(String name) {
clientInsertable.noInterceptor(name);
return this;
}
@Override
public EntityInsertable useInterceptor() {
clientInsertable.useInterceptor();
return this;
}
@Override
public EntityInsertable setSQLStrategy(boolean condition, SQLExecuteStrategyEnum sqlStrategy) {
clientInsertable.setSQLStrategy(condition, sqlStrategy);
return this;
}
@Override
public EntityInsertable asTable(Function tableNameAs) {
clientInsertable.asTable(tableNameAs);
return this;
}
@Override
public EntityInsertable asSchema(Function schemaAs) {
clientInsertable.asSchema(schemaAs);
return this;
}
@Override
public EntityInsertable asAlias(String alias) {
clientInsertable.asAlias(alias);
return this;
}
@Override
public EntityInsertable onDuplicateKeyIgnore() {
clientInsertable.onDuplicateKeyIgnore();
return this;
}
@Override
public EntityInsertable onDuplicateKeyUpdate() {
clientInsertable.onDuplicateKeyUpdate();
return this;
}
@Override
public String toSQL(T entity) {
return clientInsertable.toSQL(entity);
}
@Override
public String toSQL(T entity, ToSQLContext toSQLContext) {
return clientInsertable.toSQL(entity, toSQLContext);
}
@Override
public EntityInsertable onConflictDoUpdate() {
clientInsertable.onConflictDoUpdate();
return this;
}
@Override
public EntityInsertable onConflictDoUpdate(Property constraintProperty) {
clientInsertable.onConflictDoUpdate(EasyLambdaUtil.getPropertyName(constraintProperty));
return this;
}
@Override
public EntityInsertable onConflictDoUpdate(Property constraintProperty, SQLExpression1> setColumnSelector) {
clientInsertable.onConflictDoUpdate(EasyLambdaUtil.getPropertyName(constraintProperty), setSelector -> {
setColumnSelector.apply(new SQLColumnOnlySelectorImpl<>(setSelector));
});
return this;
}
@Override
public EntityInsertable onDuplicateKeyUpdate(SQLExpression1> setColumnSelector) {
clientInsertable.onDuplicateKeyUpdate(setSelector -> {
setColumnSelector.apply(new SQLColumnOnlySelectorImpl<>(setSelector));
});
return this;
}
@Override
public EntityInsertable batch(boolean use) {
clientInsertable.batch(use);
return this;
}
@Override
public EntityInsertable columnConfigure(SQLExpression1> columnConfigureExpression) {
clientInsertable.columnConfigure(configurer -> {
columnConfigureExpression.apply(new SQLColumnConfigurerImpl<>(configurer));
});
return this;
}
@Override
public EntityInsertable asTableLink(Function linkAs) {
clientInsertable.asTableLink(linkAs);
return this;
}
@Override
public EntityInsertable asTableSegment(BiFunction segmentAs) {
clientInsertable.asTableSegment(segmentAs);
return this;
}
@Override
public EntityInsertable configure(SQLExpression1 configurer) {
clientInsertable.configure(configurer);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy