繁体   English   中英

为什么jooq在whenNotMatchedInsert中不允许记录?

[英]Why doesn't jooq allow a Record in whenNotMatchedInsert?

在合并查询中,我始终可以执行以下操作:

public <R> void insertOrUpdateRecord(TableRecord<R> record, Condition match, Map<? extends Field<?>, ?> updates) {
    ctx.mergeInto(record.getTable()).using(ctx.selectOne())
       .on(match)
       .whenMatchedThenUpdate()
       .set(updates)
       .whenNotMatchedThenInsert(record.fields())
       .values(toArray(record));
}

在此, toArray以与record.fields()返回的相应字段相同的顺序转换TableRecord > Object[]

因此,有什么原因使我无法直接执行此操作:

whenNotMatchedThenInsert(record)

既然如此,目标几乎是插入新记录?

所需的功能已经可用,语法略有不同:

   .whenNotMatchedThenInsert()
   .set(record);

这将考虑参数Record中所有值,其中Record.changed(Field)标志为true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM