public class MapBatchInsertBuilder
extends java.lang.Object
This is not thread safe.
MapBatchInsertBuilder builder = MapBatchInsertBuilder.newInstance(config, "Emp");
builder.batchSize(10);
builder.execute(new ArrayList<Map<String, Object>>() {
{
add(new LinkedHashMap<String, Object>() {
{
put("name", "SMITH");
put("salary", 1000);
}
});
add(new LinkedHashMap<String, Object>() {
{
put("name", "ALLEN");
put("salary", 2000);
}
});
}
});
insert into Emp
(name, salary)
values('SMITH', 1000)
insert into Emp
(name, salary)
values('ALLEN', 2000)
| Modifier and Type | Method and Description |
|---|---|
void |
batchSize(int batchSize)
Sets the batch size.
|
void |
callerClassName(java.lang.String className)
Sets the caller class name.
|
void |
callerMethodName(java.lang.String methodName)
Sets the caller method name.
|
int[] |
execute(java.lang.Iterable<? extends java.util.Map<java.lang.String,java.lang.Object>> parameter)
Executes SQL INSERT statements.
|
java.util.List<? extends Sql<?>> |
getSqls()
Returns the built SQL.
|
static MapBatchInsertBuilder |
newInstance(Config config,
java.lang.String tableName)
Creates a new instance.
|
void |
queryTimeout(int queryTimeout)
Sets the query timeout limit in seconds.
|
void |
sqlLogType(SqlLogType sqlLogType)
Sets the SQL log format.
|
public static MapBatchInsertBuilder newInstance(Config config, java.lang.String tableName)
config - the configurationtableName - the table nameDomaNullPointerException - if config or tableName is nullpublic int[] execute(java.lang.Iterable<? extends java.util.Map<java.lang.String,java.lang.Object>> parameter)
parameter - the parameterparameter size.DomaNullPointerException - if parameter is nullDomaIllegalArgumentException - if parameter is emptyUniqueConstraintException - if an unique constraint violation occursJdbcException - if a JDBC related error occurspublic void queryTimeout(int queryTimeout)
If not specified, the value of Config.getQueryTimeout() is used.
queryTimeout - the query timeout limit in secondsStatement.setQueryTimeout(int)public void sqlLogType(SqlLogType sqlLogType)
sqlLogType - the SQL log format typepublic void batchSize(int batchSize)
If not specified, the value of Config.getBatchSize() is used.
batchSize - the batch sizepublic void callerClassName(java.lang.String className)
If not specified, the class name of this instance is used.
className - the caller class nameDomaNullPointerException - if className is nullpublic void callerMethodName(java.lang.String methodName)
if not specified, execute is used.
methodName - the caller method nameDomaNullPointerException - if methodName is nullpublic java.util.List<? extends Sql<?>> getSqls()