当切换到新的jOOQ Gradle插件3.19.0时,我发现另一个问题是,以前的示例实体(包括一个引用自身的字段)不起作用。
升级新的Gradle插件的尝试就在这里,
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
使现代化
:只需看到这个警告,似乎最终生成的类有效。