Migrating jooq version from 3.14.6 to 3.17.5

258 views
Skip to first unread message

deepankar gupta

unread,
Mar 16, 2023, 4:06:32 AM3/16/23
to jOOQ User Group
Hi Lucas,

I am trying to upgrade jooq version from 3.14.6 to 3.17.5. We have implemented 2 interfaces Constraint and QueryPartInternal. And also overridden toSQL(RenderContext ctx) and bind(BindContext ctx) methods but in jooq version 3.17.5 these methods are not there anymore. Need help on how these 2 methods implementation should look like in jooq version 3.17.5

Code Snippet:
private interface ConstraintInternal extends Constraint, QueryPartInternal {

    }

private Constraint useDeferrableConstraint(Constraint delegate){
        return new ConstraintInternal() {

            @Override
            public void accept(Context<?> ctx) {
                ((QueryPartInternal) (delegate)).accept(ctx);
                if (join.from().isPartitioned()) {
                    ctx.sql(" deferrable initially deferred not valid");
                } else {
                    ctx.sql(" deferrable initially deferred");
                }
            }

            @Override
            public boolean rendersContent(Context<?> ctx) {
                return  ((QueryPartInternal) (delegate)).rendersContent(ctx);
            }

            //Need help on this method(Not there anymore in jooq 3.17.5)
            @Override
            public void toSQL(RenderContext ctx) {
                ((QueryPartInternal) (delegate)).toSQL(ctx);
            }

            //Need help on this method(Not there anymore in jooq 3.17.5)
            @Override
            public void bind(BindContext ctx) throws DataAccessException {
                ((QueryPartInternal) (delegate)).bind(ctx);
            }

            @Override
            public Clause[] clauses(Context<?> ctx) {
                return ((QueryPartInternal) (delegate)).clauses(ctx);
            }

            @Override
            public boolean declaresFields() {
                return ((QueryPartInternal) (delegate)).declaresFields();
            }

            @Override
            public boolean declaresTables() {
                return ((QueryPartInternal) (delegate)).declaresTables();
            }

            @Override
            public boolean declaresWindows() {
                return  ((QueryPartInternal) (delegate)).declaresWindows();
            }

            @Override
            public boolean declaresCTE() {
                return ((QueryPartInternal) (delegate)).declaresCTE();
            }

            //Need to override this method in jooq 3.17.5
            @Override
            public boolean declaresParameters() {
                return false;
            }

            @Override
            public boolean generatesCast() {
                return ((QueryPartInternal) (delegate)).generatesCast();
            }

            @Override
            public String getName() {
                return delegate.getName();
            }

            @Override
            public Name getQualifiedName() {
                return delegate.getQualifiedName();
            }

            @Override
            public Name getUnqualifiedName() {
                return delegate.getUnqualifiedName();
            }

            @Override
            public String getComment() {
                return delegate.getComment();
            }

            @Override
            public Comment getCommentPart() {
                return delegate.getCommentPart();
            }

            //Need to override this method in jooq 3.17.5
            @Override
            public @org.jetbrains.annotations.NotNull Name $name() {
                return delegate.$name();
            }

            @Override
            public String toString() {
                if (join.from().isPartitioned()) {
                    return delegate.toString() + " deferrable initially deferred not valid";
                } else {
                    return delegate.toString() + " deferrable initially deferred";
                }
            }

            //Need to override this method in jooq 3.17.5
            @Override
            public <R> R $traverse(Traverser<?, R> traverser) {
                return delegate.$traverse(traverser);
            }

            //Need to override this method in jooq 3.17.5
            @Override
            public @org.jetbrains.annotations.NotNull QueryPart $replace(Replacer replacer) {
                return delegate.$replace(replacer);
            }
        };
    }

Lukas Eder

unread,
Mar 16, 2023, 4:20:45 AM3/16/23
to jooq...@googlegroups.com
Hi Deepankar,

Thanks a lot for your message. That's an interesting approach, I can see how that works for you. The fact that you're implementing interfaces like these (especially the one that is called QueryPartInternal) hints at there being a feature request hidden in there somewhere. Things can break when implementing internal interfaces. Besides, we'll "soon" seal the entire DSL type hierarchy, because most attempts at implementing the DSL API (e.g. Constraint) should also be considered tweaking internals and are usually not the best way to achieve something.

I'd love to get a bit more context on your use-case here. It seems that you would like to add some DDL clause support to your constraints when using jOOQ's CREATE TABLE or ALTER TABLE support? Is it this feature you're looking for?

Maybe, it's worth investigating also the option of supporting plain SQL TableElement and CustomTableElement implementations, which allow for adding arbitrary clauses to DDL statements, which jOOQ doesn't support (yet). I've created a feature request for this:

Back to what broke here, the internal rendering API got changed a long time ago with:

And the old internal API was removed with:

This change allows for traversing an expression tree only once to do both actions in one go:
- SQL generation
- Bind value collection

In any case, I think you already correctly implemented the interfaces, with your accept() method. You can now just remove the toSQL() and bind() methods, which are no longer necessary.
Does that solve your problem?

Best Regards,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/71aaa0ae-71f0-450b-b3ec-db081635ddfen%40googlegroups.com.

deepankar gupta

unread,
Mar 17, 2023, 5:29:58 AM3/17/23
to jOOQ User Group
Hi Lucas,
Thanks for such in-depth insights. Yeah it solves my problem

Regards
Deepankar Gupta

deepankar gupta

unread,
Mar 20, 2023, 4:16:54 AM3/20/23
to jOOQ User Group
Hi Lucas,

Can you please help me with external dependencies that is compatible with jooq 3.17.5. From chatgpt, I come up with below dependencies:

Here are the external dependencies used by jOOQ 3.17.5:

  • asm: 7.2 (Apache License 2.0)
  • cglib: 3.3.0 (Apache License 2.0)
  • jakarta.activation: 1.2.2 (Apache License 2.0)
  • jakarta.annotation-api: 1.3.5 (Eclipse Public License 2.0)
  • jakarta.xml.bind-api: 2.3.3 (Eclipse Public License 2.0)
  • jakarta.xml.soap-api: 1.4.2 (Eclipse Public License 2.0)
  • jakarta.xml.ws-api: 2.3.3 (Eclipse Public License 2.0)
  • javax.activation: 1.2.0 (Common Development and Distribution License 1.0)
  • javax.xml.bind: 2.3.3 (Common Development and Distribution License 1.0)
  • javax.xml.soap: 1.4.0 (Common Development and Distribution License 1.0)
  • javax.xml.ws: 2.3.3 (Common Development and Distribution License 1.0)
  • jdom2: 2.0.6 (Apache License 2.0)
  • log4j-api: 2.14.1 (Apache License 2.0)
  • log4j-core: 2.14.1 (Apache License 2.0)
  • org.eclipse.jdt.core.compiler: 3.25.0 (Eclipse Public License 1.0)
  • org.jooq: jooq-meta: 3.17.5 (Apache License 2.0)
  • org.jooq: jooq-codegen: 3.17.5 (Apache License 2.0)
  • org.postgresql: postgresql: 42.2.18 (BSD-style license)
  • org.slf4j: slf4j-api: 1.7.30 (MIT License)
Do let me know if any dependency is missing or version is not correct.

Regards
Deepankar Gupta

Lukas Eder

unread,
Mar 20, 2023, 4:40:13 AM3/20/23
to jooq...@googlegroups.com
Hi Deepankar,

ChatGPT produces inaccurate results. See:

The mere fact that this output suggest you add soap to your list of dependencies should be a red flag.

I hope this helps,
Lukas

deepankar gupta

unread,
Mar 20, 2023, 4:52:37 AM3/20/23
to jOOQ User Group
Hi Lucas,
Is there any documentation I can refer to, to get all list of dependencies compatible with jooq 3.17.5??

Regards
Deepankar Gupta

Lukas Eder

unread,
Mar 20, 2023, 4:56:37 AM3/20/23
to jooq...@googlegroups.com
All the dependencies are documented in the pom.xml file of the relevant artifact. Use mvn dependency:tree on your project to visualise them

deepankar gupta

unread,
Mar 25, 2023, 4:36:30 AM3/25/23
to jOOQ User Group
Hi Lucas,

I was comparing both 3.14.6 and 3.17.5 versions, there you mentioned that we have to explicitly specify jaxb api in jooq 3.14.6 version. And in 3.17.5 you have replaced jaxb-api with jakarta.xml.bind-api. The same will have to do for jakarta.xml.bind-api as well. Do we have to explicitly specify jakarta.xml.bind-api for 3.17.5 version?? And we have to use jakarta.xml.bind-api 3.0.0 version.

Regards
Deepankar Gupta
Screenshot 2023-03-25 at 1.59.23 PM.png

Lukas Eder

unread,
Mar 27, 2023, 2:34:50 AM3/27/23
to jooq...@googlegroups.com
Hi Deepankar,

There are two points to this discussion:

- What dependencies jOOQ exposes (and indeed, there has been a change from javax to Jakarta EE namespaces)
- What this means for you, specifically

I don't want to give you any guidelines with respect to what you "have to" do, because I don't know your setup. All of our examples and integration tests don't do anything special. They just add the jOOQ dependency, and stuff works, because Maven loads all necessary transitive dependencies automatically, and the optional ones are... well, optional.

Do you have any *specific* problems I can help you with?
Best Regards,
Lukas

deepankar gupta

unread,
Mar 29, 2023, 1:11:54 AM3/29/23
to jOOQ User Group
Hi Lucas,
Since jooq 3.17.5 uses  jakarta.xml.bind-api 3.0.0 version and in this version java.xml.bind (JAXB)  has been REMOVED. So my question is, will jooq 3.17.5 work with a lower version of jakarta.xml.bind-api 2.3.3?


Regards
Deepankar Gupta

Lukas Eder

unread,
Mar 29, 2023, 3:22:05 AM3/29/23
to jooq...@googlegroups.com
jOOQ will require at least the JAXB API version that it declares.

Of course, lower versions *might* work by accident (and probably will, because the JAXB dependency isn't used much anymore, apart from the annotations), but if you want to be sure to use only what's being integration tested, then please use the declared (as in the pom.xml) version. If you have strict versioning policies, then that might just mean (though again, I can impossibly be the judge here), you can't upgrade jOOQ before you upgrade also JAXB.

In jOOQ 3.18.0, the dependency has been marked optional, so you could possibly even remove it on your end, if you can accept this warning here:

I hope this helps
Lukas

Reply all
Reply to author
Forward
0 new messages