io.github.sinri.keel.mysql.statement.WriteIntoStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.mysql.statement;
import io.github.sinri.keel.mysql.NamedMySQLConnection;
import io.github.sinri.keel.mysql.Quoter;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.sqlclient.SqlConnection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static io.github.sinri.keel.helper.KeelHelpersInterface.KeelHelpers;
public class WriteIntoStatement extends AbstractModifyStatement {
/**
* insert [ignore] into schema.table (column...) values (value...),... ON DUPLICATE KEY UPDATE assignment_list
* insert [ignore] into schema.table (column...) [select ...| table ...] ON DUPLICATE KEY UPDATE assignment_list
*/
public static final String INSERT = "INSERT";
public static final String REPLACE = "REPLACE";
@Nonnull
final List columns = new ArrayList<>();
@Nonnull
final List> batchValues = new ArrayList<>();
@Nonnull
final Map onDuplicateKeyUpdateAssignmentMap = new HashMap<>();
@Nonnull
final String writeType;
@Nonnull
String ignoreMark = "";
@Nullable
String schema;
@Nonnull
String table = "TABLE-NOT-SET";
@Nullable
String sourceSelectSQL;
@Nullable
String sourceTableName;
public WriteIntoStatement() {
this.writeType = INSERT;
}
public WriteIntoStatement(@Nonnull String writeType) {
this.writeType = writeType;
}
public WriteIntoStatement intoTable(@Nonnull String table) {
if (table.isBlank()) throw new IllegalArgumentException("Table is blank");
this.table = table;
return this;
}
public WriteIntoStatement intoTable(@Nullable String schema, @Nonnull String table) {
this.schema = schema;
this.table = table;
return this;
}
public WriteIntoStatement ignore() {
this.ignoreMark = "IGNORE";
return this;
}
public WriteIntoStatement columns(@Nonnull List columns) {
this.columns.addAll(columns);
return this;
}
public WriteIntoStatement addDataMatrix(@Nonnull List> batch) {
for (List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy