Search code examples
jooqjooq-codegen

Why does Jooq Code Generator makes un-necessary changes to all files?


I'm using Jooq Code Generator and I noticed that when I make a change in the DB and run the code generator, it makes changes to all files, not just to those that should have been changed.

For example, I add a new table, so I see the new class for the table, and the new class for the table record, and I see that the table was added to the schema class. But in classes that represent other tables, that shouldn't have been affected at all, I also see changes, in the "imports" section.

In some files I see that just an empty line was added. In others I see that the location of specific import lines was changed. And in other classes, a line of import that contains * is replaced by the entire list of imported classes, or vice-versa.

Example: some lines change place, others are replaced

My questions are: Why does Jooq does that?? And can I turn this behavior off?

Thanks!


Solution

  • The jOOQ code generator doesn't produce that particular import you've shown, i.e. import org.jooq.*;. You must have done that yourself, either manually, or via some post processing on generated code.

    • If you did this manually, then this is clearly against the idea of what jOOQ generated code should be, namely derived code, which shouldn't be modified manually. It wouldn't be possible for the code generator to detect which parts you modified (and intend to keep) and which parts you didn't modify (and are thus allowed to be overwritten). Just don't do that.
    • If you did this via automated post processing, then jOOQ's code generator still cannot detect this, but after overwriting everything, you would just have to re-apply this post processing, and the end result should be unmodified code.