bulkInsertReturning
Bulk insert records to the table and return the specific column's values.
Usage:
database.bulkInsertReturning(Employees, Employees.id) {
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)
}
}
Generated SQL:
insert into table (name, job, manager_id, hire_date, salary, department_id)
values (?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)...
returning id
Since
3.6.0
Return
the returning column's values.
Parameters
the table to be inserted.
the column to return
the DSL block, extension function of BulkInsertStatementBuilder, used to construct the expression.
Bulk insert records to the table and return the specific columns' values.
Usage:
database.bulkInsertReturning(Employees, Pair(Employees.id, Employees.job)) {
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)
}
}
Generated SQL:
insert into table (name, job, manager_id, hire_date, salary, department_id)
values (?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)...
returning id, job
Since
3.6.0
Return
the returning columns' values.
Parameters
the table to be inserted.
the columns to return
the DSL block, extension function of BulkInsertStatementBuilder, used to construct the expression.
Bulk insert records to the table and return the specific columns' values.
Usage:
database.bulkInsertReturning(Employees, Triple(Employees.id, Employees.job, Employees.salary)) {
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)
}
}
Generated SQL:
insert into table (name, job, manager_id, hire_date, salary, department_id)
values (?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)...
returning id, job, salary
Since
3.6.0
Return
the returning columns' values.
Parameters
the table to be inserted.
the columns to return
the DSL block, extension function of BulkInsertStatementBuilder, used to construct the expression.