Skip to content

fix(jooq): resolve DSLContext injection ambiguity#1911

Open
graemerocher wants to merge 1 commit into7.0.xfrom
fix-issue-1292-jooq-dslcontext
Open

fix(jooq): resolve DSLContext injection ambiguity#1911
graemerocher wants to merge 1 commit into7.0.xfrom
fix-issue-1292-jooq-dslcontext

Conversation

@graemerocher
Copy link
Copy Markdown
Contributor

Summary

  • split the internal jOOQ JDBC and R2DBC configuration beans into distinct types
  • create separate DSLContext beans and make the R2DBC-backed DSLContext primary when both are present
  • add a focused regression spec covering default DSLContext injection with JDBC and R2DBC together

Verification

@graemerocher graemerocher added the type: bug Something isn't working label Apr 15, 2026
@graemerocher graemerocher self-assigned this Apr 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Resolves Micronaut jOOQ DSLContext injection ambiguity when both JDBC and R2DBC configurations are present by separating configuration bean types and adjusting DSLContext bean creation/selection.

Changes:

  • Introduce distinct internal JdbcConfiguration and R2dbcConfiguration bean types (both extend jOOQ DefaultConfiguration).
  • Update JDBC/R2DBC configuration factories to return those distinct types and refactor shared configuration setup into a generic helper.
  • Create separate DSLContext beans for JDBC vs R2DBC configurations and add a regression spec for the combined setup.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
jooq/src/main/java/io/micronaut/configuration/jooq/AbstractJooqConfigurationFactory.java Refactors shared configuration wiring into configureConfiguration(T) to support distinct config subtypes.
jooq/src/main/java/io/micronaut/configuration/jooq/JooqConfigurationFactory.java Produces JdbcConfiguration instead of generic Configuration.
jooq/src/main/java/io/micronaut/configuration/jooq/R2dbcJooqConfigurationFactory.java Produces R2dbcConfiguration instead of generic Configuration.
jooq/src/main/java/io/micronaut/configuration/jooq/JdbcConfiguration.java New internal JDBC configuration subtype to disambiguate beans.
jooq/src/main/java/io/micronaut/configuration/jooq/R2dbcConfiguration.java New internal R2DBC configuration subtype to disambiguate beans.
jooq/src/main/java/io/micronaut/configuration/jooq/DSLContextFactory.java Splits DSLContext creation per config type and marks the R2DBC one as primary.
jooq/src/test/groovy/io/micronaut/configuration/jooq/DslContextFactorySpec.groovy Adds regression spec validating default DSLContext injection when both JDBC and R2DBC are present.

Comment on lines +53 to +56
@Primary
@EachBean(R2dbcConfiguration.class)
DSLContext r2dbcDslContext(@Parameter R2dbcConfiguration configuration) {
return createDslContext(configuration);
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Primary on an @EachBean(R2dbcConfiguration.class) factory method makes every generated R2DBC DSLContext primary. If the app has multiple ConnectionFactory/R2dbcConfiguration beans (e.g., default + others), this will produce multiple primary DSLContext beans and reintroduce injection ambiguity for unqualified DSLContext injection. Consider avoiding method-level @Primary and instead expose a single primary/alias DSLContext bean that points to the desired default (e.g., the primary R2dbcConfiguration), or apply @Primary only to the default instance via qualifier-based selection.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants