When switching to the new jOOQ Gradle plugin 3.19.0, another issue I found the former example entity which includes a field refers to itself does not work.
The attempt of upgrading new Gradle plugin is here, https://github.com/hantsy/spring-r2dbc-sample/pull/320
The table that caused the problem.
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] */;
When running ./gradlew clean jooqCodegenMain
command, you will see the following warning message.
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/
But the original version using nu.studer.jooq
plugin was working well: https://github.com/hantsy/spring-r2dbc-sample/tree/master/jooq-kotlin-co-gradle
Update: just see this warning, it seems the final generated classes worked.
This isn't a bug. Starting with jOOQ 3.19, there is now support for to-many relationship paths. The DefaultGeneratorStrategy
uses the same naming pattern for to-many
paths as it does for to-one
paths. If your table is self-referential, then there's a naming conflict, and the to-many
path is simply not generated.
You can either:
implicitJoinPathsToMany = false
Note, the nu.studer.jooq
plugin will also generate this warning, as soon as it supports jOOQ 3.19