jooqjooq-codegen-mavenjooq-codegen

How to exclude an identity column from JOOQ code generation?


I have an identity column like below

alter table google_co2_emission_data
    add column co2_data_id bigint generated always as identity primary key;

I want to exclude co2_data_id from jooq code generation. By generator configuration looks like below

<generator>
    <database>
      <name>org.jooq.meta.postgres.PostgresDatabase</name>
      <includes>.*</includes>
      <excludes>.*\.gossiper_update_v2 | .*\.kv_store | .*\.single_run_trigger | .*\.lease
        | .*\.gossiper_update_v2_checkpoint | .*\.google_co2_emission_data.co2_data_id
      </excludes>
      <inputSchema>public</inputSchema>
    </database>
</generator>

I am still seeing code is being generated for google_co2_emission_data.co2_data_id. Is it possible to exclude an identity primary column from JOOQ code generation?


Solution

  • By default, the <includes> and <excludes> elements don't match columns, only schema objects. In order for it to match columns as well, use an additional <includeExcludeColumns/> flag. See also the documentation.

    I.e.

    <generator>
        <database>
          <name>org.jooq.meta.postgres.PostgresDatabase</name>
          <includes>.*</includes>
          <excludes>
              .*\.gossiper_update_v2
            | .*\.kv_store
            | .*\.single_run_trigger
            | .*\.lease
            | .*\.gossiper_update_v2_checkpoint 
            | .*\.google_co2_emission_data.co2_data_id
          </excludes>
          <includeExcludeColumns>true</includeExcludeColumns>
          <inputSchema>public</inputSchema>
        </database>
    </generator>