当切换到新的jOOQ Gradle插件3.19.0时,我发现另一个问题,我发现以前的示例实体包含一个字段引用本身不起作用.

升级新Gradle插件的try 在这里,https://github.com/hantsy/spring-r2dbc-sample/pull/320

导致问题的桌子.

CREATE TABLE IF NOT EXISTS nodes (
    id UUID NOT NULL /* [jooq ignore start] */ DEFAULT uuid_generate_v4() /* [jooq ignore stop] */,
    name VARCHAR(50),
    description VARCHAR(255),
    parent_id UUID
);
ALTER TABLE nodes ADD CONSTRAINT nodes_pk PRIMARY KEY (id);
ALTER TABLE nodes ADD CONSTRAINT nodes_parent_fk FOREIGN KEY (parent_id) REFERENCES nodes(id) /* [jooq ignore start] */ON UPDATE CASCADE/* [jooq ignore stop] */;

当运行./gradlew clean jooqCodegenMain命令时,您将看到以下警告消息.

Ambiguous key name       : The database object nodes_parent_fk generates an inbound key method name nodes which conflicts with the previously generated outbound key method name. Use a 
custom generator strategy to disambiguate the types. More information here:
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-generatorstrategy/
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/

但使用nu.studer.jooq插件的原始版本运行良好:https://github.com/hantsy/spring-r2dbc-sample/tree/master/jooq-kotlin-co-gradle

Update:看看这条警告,似乎最终生成的类起作用了.

推荐答案

这不是一个窃听器.从jOOQ 3.19开始,现在支持to-many relationship paths.DefaultGeneratorStrategyto-many条路径使用与对to-one条路径相同的命名模式.如果您的表是自引用的,那么就会存在命名冲突,并且根本不会生成to-many路径.

您可以执行以下任一操作:

  • Turn off the feature使用implicitJoinPathsToMany = false
  • 忽略该警告
  • 实现生成器策略以消除名称的歧义

请注意,一旦支持jOOQ 3.19,nu.studer.jooq插件也会生成此警告

Kotlin相关问答推荐

API迁移到Spring Boot 3后,Spring Security无法工作

在Kotlin 有更好的结合方式?

相当于roomdb中的DateTime Bigint列的是什么

数据流弹性模板失败,出现错误&未知非复合转换urn";

如何让 LocalDateTime.parse 拒绝 24:00 时间

为什么Kotlin有次构造函数和init块?

使用 LazyListScope 嵌套可组合项

如何在kotlin中使用协程每秒调用一个函数

Kotlin JS JSON 反序列化

Map.mapTo 到另一个map

有没有办法在spring webflux和spring data react中实现分页

如何在使用 Gradle 的 AppEngine 项目中使用 Kotlin

如何使用协调器布局和行为在CardView上完成此动画?

Kotlin中OnclickListener方法之间的差异

如何让数据类在Kotlin中实现接口/扩展超类属性?

Android:Exoplayer - ExtractorMediaSource 已弃用

Kotlin扩展函数与成员函数?

旋转 kotlin 数组

为什么 Kotlin 会收到这样的 UndeclaredThrowableException 而不是 ParseException?

如何在 Kotlin 中生成 MD5 哈希?