v3.4.0
Support Locking Clause for MySQL & PostgreSQL #247
Now Ktorm supports locking clause like for update, for share both for MySQL & PostgreSQL, for example:
val employee = database.employees
.filter { it.name eq "vince" }
.locking(LockingMode.FOR_UPDATE, wait = LockingWait.SKIP_LOCKED)
.firstOrNull()Generated SQL:
SELECT *
FROM t_employee
WHERE t_employee.name = ?
LIMIT ?, ?
FOR UPDATE SKIP LOCKEDRefer to these two functions for detailed usage:
Support insert ... returning ... for PostgreSQL #233
With an insert ... returning ... statement, we can insert records to the database, and at the same time, retrieve some generated columns. For example:
val id = database.insertReturning(Employees, Employees.id) {
set(it.name, "pedro")
set(it.job, "engineer")
set(it.salary, 1500)
set(it.hireDate, LocalDate.now())
set(it.departmentId, 1)
}Returning multiple columns is also supported:
val (id, job) = database.insertReturning(Employees, Pair(Employees.id, Employees.job)) {
set(it.name, "vince")
set(it.job, "engineer")
set(it.salary, 1000)
set(it.hireDate, LocalDate.now())
set(it.departmentId, 1)
}Generated SQL:
insert into t_employee (name, job, salary, hire_date, department_id)
values (?, ?, ?, ?, ?) returning id, jobThere are also some other versions of xxxReturning functions, check the API docs for details:
Other Optimizations & Bug Fixes
- PostgreSQL: support
onConflict { doNothing() }forinsertOrUpdate&bulkInsertOrUpdate#255 PostgreSQL: Fix type mismatch error forJsonSqlType#268- Value semantics for Entity: add default
equals&hashCodefunction #242 - Auto transformation between JSR-310 classes and JDBC date & time #252
- Support using unsigned integers as column types #253
- Fix null-value-ignoring bug for
addfunction #273