Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
Implicit JOIN paths
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Implicit JOINs are one of jOOQ's most powerful synthetic SQL features, which depends entirely on code generation. The code generator produces links between tables that follow:
-
to-one
relationships (i.e. from child table to parent table) - (Other relationships are supported starting from jOOQ 3.19)
This way, it is possible to greatly simplify your queries:
// Get all books, their authors, and their respective language create.select( BOOK.author().FIRST_NAME, BOOK.author().LAST_NAME, BOOK.TITLE, BOOK.language().CD.as("language")) .from(BOOK) .fetch();
The feature has a few feature toggles in the code generator, including:
<configuration> <generator> <generate> <!-- Allowing to turn off the feature for to-one join paths (including many-to-many). The default is true. --> <implicitJoinPathsToOne>true</implicitJoinPathsToOne> <!-- Influencing how the DefaultGeneratorStrategy generates identifiers. The default is true. When a child table has only one FK towards a parent table, then that path is "unambiguous." In that case, the DefaultGeneratorStrategy uses the parent table name instead of the FK name. --> <implicitJoinPathsUseTableNameForUnambiguousFKs>true</implicitJoinPathsUseTableNameForUnambiguousFKs> <!-- Tell the KotlinGenerator to generate properties in addition to methods for these paths. The default is true. --> <implicitJoinPathsAsKotlinProperties>true</implicitJoinPathsAsKotlinProperties> </generate> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator( new Generate() // Allowing to turn off the feature for to-one join paths (including many-to-many). // The default is true. .withImplicitJoinPathsToOne(true) // Influencing how the DefaultGeneratorStrategy generates identifiers. // The default is true. // // When a child table has only one FK towards a parent table, then that path is "unambiguous." // In that case, the DefaultGeneratorStrategy uses the parent table name instead of the FK name. .withImplicitJoinPathsUseTableNameForUnambiguousFKs(true) // Tell the KotlinGenerator to generate properties in addition to methods for these paths. // The default is true. .withImplicitJoinPathsAsKotlinProperties(true) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { generate { // Allowing to turn off the feature for to-one join paths (including many-to-many). // The default is true. implicitJoinPathsToOne = true // Influencing how the DefaultGeneratorStrategy generates identifiers. // The default is true. // // When a child table has only one FK towards a parent table, then that path is "unambiguous." // In that case, the DefaultGeneratorStrategy uses the parent table name instead of the FK name. implicitJoinPathsUseTableNameForUnambiguousFKs = true // Tell the KotlinGenerator to generate properties in addition to methods for these paths. // The default is true. implicitJoinPathsAsKotlinProperties = true } } }
See the configuration XSD and gradle code generation for more details.
Feedback
Do you have any feedback about this page? We'd love to hear it!