batchInsert
fun <T : BaseTable<*>> T.batchInsert(block: BatchInsertStatementBuilder<T>.() -> Unit): IntArray(source)
Deprecated
ktorm-global will be removed in the future, please migrate to the standard API.
Construct insert expressions in the given closure, then batch execute them and return the effected row counts for each expression.
Note that this function is implemented based on Statement.addBatch and Statement.executeBatch, and any item in a batch operation must have the same structure, otherwise an exception will be thrown.
Usage:
Employees.batchInsert {
item {
set(it.name, "jerry")
set(it.job, "trainee")
set(it.managerId, 1)
set(it.hireDate, LocalDate.now())
set(it.salary, 50)
set(it.departmentId, 1)
}
item {
set(it.name, "linda")
set(it.job, "assistant")
set(it.managerId, 3)
set(it.hireDate, LocalDate.now())
set(it.salary, 100)
set(it.departmentId, 2)
}
}
Content copied to clipboard
Return
the effected row counts for each sub-operation.
Parameters
block
the DSL block, extension function of BatchInsertStatementBuilder, used to construct the expressions.