如何获取生成的表的行表示形式? [英] How to get a Row representation of a generated table?

查看:78
本文介绍了如何获取生成的表的行表示形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取生成的JOOQ表类型的Row[N]<...>表示形式.我想在这种情况下使用它:

I want to get Row[N]<...> representation of a generated JOOQ table type. I want to use it in this context:

val p = PROJECTS.`as`("p")
val pmu = PROJECTMEMBERUSERS.`as`("pmu")
val query = db
    .select(p.asterisk(), DSL.arrayAgg(DSL.rowField(<-- insert Row[N]<...> here -->)))
    .from(p.join(pmu).on(p.ID.eq(pmu.PROJECTID)))
    .groupBy(p.ID)

我已经尝试插入pmu.fieldsRow(),但是DSL.rowField(...)需要另一个参数类型.

I already tried inserting pmu.fieldsRow(), but DSL.rowField(...) expects another parameter type.

错误:(39,58)Kotlin:使用提供的参数无法调用以下函数[...]

Error:(39, 58) Kotlin: None of the following functions can be called with the arguments supplied [...]

此问题是对使用的后续问题在JOOQ DSL中具有连接别名的PosgreSQL array_agg ,但应独立存在.

This question is a follow up question to Using PosgreSQL array_agg with join alias in JOOQ DSL but should be self contained.

推荐答案

jOOQ 3.11中的缺少功能

jOOQ代码生成器似乎缺少一个功能,该功能是生成的Table.fieldsRow()覆盖的方法,该方法提供了更窄的协变Row[N]<...>返回类型.我为此创建了一个功能请求,将在jOOQ 3.12中实现: https://github.com/jOOQ/jOOQ/issues/7809

Missing feature in jOOQ 3.11

There seems to be a missing feature in the jOOQ code generator, a generated Table.fieldsRow() overridden method that provides a more narrow, covariant Row[N]<...> return type. I've created a feature request for this, to be implemented in jOOQ 3.12: https://github.com/jOOQ/jOOQ/issues/7809

也缺少一个重载的DSL.rowField(RowN)方法: https://github.com/jOOQ/jOOQ/issues/7810

Also missing, an overloaded DSL.rowField(RowN) method: https://github.com/jOOQ/jOOQ/issues/7810

这是最明显的解决方法,您显然要避免:明确列出所有列名:

This is the most obvious workaround, which you obviously want to avoid: Listing all the column names explicitly:

row(pmu.COL1, pmu.COL2, ..., pmu.COLN)

解决方法,使用生成的记录

在生成的记录中已经有 这样的生成方法.解决方法是,您可以使用

Workaround, use generated records

There already is such a generated method in generated records. As a workaround, you could use

new ProjectMembersUsersRecord().fieldsRow();

解决方法,扩展代码生成器

您现在可以通过使用自定义代码部分扩展JavaGenerator来自己实现#7809:

Workaround, extend the code generator

You can implement #7809 yourself already now, by extending the JavaGenerator with a custom code section:

https://www.jooq.org /doc/latest/manual/code-generation/codegen-custom-code

这篇关于如何获取生成的表的行表示形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆