Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add org.jooq.AutoForcedType to auto-detect Converter and Binding types from the classpath of the code generator #13167

Open
lukaseder opened this issue Mar 1, 2022 · 2 comments

Comments

@lukaseder
Copy link
Member

lukaseder commented Mar 1, 2022

jOOQ 3.17 added support for auto-configuration of jooq-postgres-extensions data type bindings if found on the classpath (#10763). This is very convenient for the known built-in types for cidr, inet, and hstore (and more in the future).

But the mechanism could also be useful for custom data types implemented by end users, who know they want to apply those on all of their code generation, by default.

To configure this, an annotation could be added to Converter or Binding classes. It would reflect most of the ForcedType contents:

@interface ForcedType {
    int priority() default 0;
    String userType();
    String excludeExpression();
    String includeExpression();
    String sql();
    String excludeTypes();
    String includeTypes();
    Nullability nullability();
    ForcedTypeObjectType objectType();
}

Once available, the implementation of #10763 will be retrofitted to use this annotation, instead.

It's not clear yet where the annotation will be located:

  • In jooq / org.jooq it would be accessible to jooq-postgres-extensions, but it couldn't access the org.jooq.meta.jaxb.* types.
  • In jooq-meta / org.jooq.meta it could access the org.jooq.meta.jaxb.* types, but it wouldn't be accessible to jooq-postgres-extensions

How we scan the classpath is still open. A spring dependency should be avoided, but is certainly an option.

@lukaseder lukaseder added this to the Version 3.17.0 milestone Mar 1, 2022
@lukaseder lukaseder added this to To do in 3.15 Dialect Extensions via automation Mar 2, 2022
@lukaseder lukaseder changed the title Add a way to auto-detect Converter and Binding types from the classpath of the code generator Add org.jooq.meta.AutoForcedType to auto-detect Converter and Binding types from the classpath of the code generator Mar 15, 2022
@lukaseder lukaseder changed the title Add org.jooq.meta.AutoForcedType to auto-detect Converter and Binding types from the classpath of the code generator Add org.jooq.AutoForcedType to auto-detect Converter and Binding types from the classpath of the code generator Mar 15, 2022
@axelfontaine
Copy link

My vote clearly goes towards

In jooq / org.jooq it would be accessible to jooq-postgres-extensions, but it couldn't access the org.jooq.meta.jaxb.* types.

Keeping jOOQ a zero dependency library (which unfortunately it isn't anymore, but it hasn't drifted too far yet) should still be the north star to follow.

Adding a new dependency on JAXB or Spring would be a mistake that would negatively affect users as it eventually will cause transitive dependency version conflicts down the road. I made this mistake in Flyway 1.x and had to learn this the hard way.

@lukaseder
Copy link
Member Author

jOOQ already has a JAXB API dependency, always did. It used to be part of the JDK since JDK 6. But that's irrelevant to this task. The package name org.jooq.meta.jaxb hints at contents having been xjc generated and JAXB annotated (you can load your code generation configuration from XML using JAXB), but JAXB isn't essential to that API in general.

The Spring dependency could be an option in one of these jOOQ-xyz-extension modules, especially in the code generation ones. But I'm positive there are better options, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants