Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin JOOQ:如何在通过记录更新时添加returning子句_Kotlin_Jooq - Fatal编程技术网

Kotlin JOOQ:如何在通过记录更新时添加returning子句

Kotlin JOOQ:如何在通过记录更新时添加returning子句,kotlin,jooq,Kotlin,Jooq,我当前正在使用以下命令更新表: fun <T: MyRecordInterface<*>> updateRecord(record: T) { record.setField1("field1") record.setField2("field2") record.update() } 我想在更新后返回完整的更新记录,因此我执行了以下操作: fun <T: MyRecordInterface<*>> updateRecord

我当前正在使用以下命令更新表:

fun <T: MyRecordInterface<*>> updateRecord(record: T) {
   record.setField1("field1")
   record.setField2("field2")

   record.update()
}

我想在更新后返回完整的更新记录,因此我执行了以下操作:

fun <T: MyRecordInterface<*>> updateRecord(record: T): T {
   record.setField1("field1")
   record.setField2("field2")

   record.update()
   record.refresh()

   return record
}
fun更新记录(记录:T):T{
记录setField1(“field1”)
记录setField2(“field2”)
record.update()
record.refresh()
返回记录
}

是否可以将returning子句添加到更新查询中,这样我就不必在此方法中发出2个查询?

您可以打开
设置。ReturnAllonUpdateRecord
全局,它将自动为您在每个
存储()上获取所有结果值(标识、触发生成的值等)。
insert()
update()
调用

这是全局应用的,并且会产生一些开销,特别是当您不希望得到这些结果值时,因此,只有在真正需要时才使用新的
配置
和上述
设置

fun <T: MyRecordInterface<*>> updateRecord(record: T): T {
   record.setField1("field1")
   record.setField2("field2")

   record.update()
   record.refresh()

   return record
}