JOOQ - is it possible to set, for which tables i want to generate POJO (different than records)?

48 Views Asked by At

we are using JOOQ generated Records in our application even for use in presentation layer (i know thats kind of antipattern here, but i cannot refactor everything at once).

What I am trying to reach is generate not only Records, but also Pojos, but selectively only for tables specified. We are already using exclude for tables we are not interested in having Record classes. Is there any option to set include directive just for Pojo generation?

We have hundreds of tables in our DB and I need only about 10 Pojos now. And because tables have quite a lot of columns I would rather automate Pojos generation than write them by myself. We want to slowly get rid of the antipattern mentioned earlier, but step by step, not at once. And many of Records dont need to be in presentation layer so no need to have a Pojo class for every Record.

I cannot use Records anymore because i need to serialize old records to XML file and export them out of DB while "fresh" data remains in DB. Pojos should be best solution for fetching "fresh" data from DB and access old data via deserialization from XML archive while all data together may be presented in GUI in the same way.

Thank you for suggestions

1

There are 1 best solutions below

0
Lukas Eder On

There's a pending feature request for this:

I'm not convinced this will be implemented soon, given how much complexity for little value it will add to the code generator.

You can easily implement this on your end by running the code generator twice, though. Once without pojos and once with only pojos. In that case, you can have separate includes / excludes configurations.

If you're using Maven, you can use <pluginManagement/> to configure the common parts. See also:

I cannot use Records anymore because i need to serialize old records to XML file and export them out of DB while "fresh" data remains in DB. Pojos should be best solution for fetching "fresh" data from DB and access old data via deserialization from XML archive while all data together may be presented in GUI in the same way.

Why not just use jOOQ's built-in XML export functionality?