【发布时间】:2021-12-17 22:47:11
【问题描述】:
使用 Jooq,我尝试先通过 id 从表中获取,如果未找到匹配项,则再次通过 handle 获取。
我想要返回行的所有字段,而不仅仅是一个。
Field<?> firstMatch = DSL.select(Tables.MY_TABLE.fields())
.from(Tables.MY_TABLE.fields())
.where(Tables.MY_TABLE.ID.eq(id))
.asfield(); // This is wrong, because it supports only one field, but above we selected Tables.MY_TABLE.fields(), which is plural.
Field<?> secondMatch = DSL.select(Tables.MY_TABLE.fields())
.from(Tables.MY_TABLE.fields())
.where(Tables.MY_TABLE.HANDLE.eq(handle))
.asfield(); // Same as above.
dslContext.select(DSL.coalesce(firstMatch, secondMatch))
.fetchInto(MyClass.class);
由于上述代码中的错误,出现如下错误:
Can only use single-column ResultProviderQuery as a field
我想知道如何制作 firstMatch 和 secondMatch 两个字段列表,而不是两个字段?
我试过了
Field<?>[] secondMatch = DSL.select(Tables.MY_TABLE.fields())
.from(Tables.MY_TABLE.fields())
.where(Tables.MY_TABLE.HANDLE.eq(handle))
.fields();
但在包含DSL.coalesce的行出现以下错误
Type interface org.jooq.Field is not supported in dialect DEFAULT
提前致谢!
【问题讨论】: