jooqjooq-codegen-mavenjooq-codegen

JOOQ codegen not working when added fields in both includes and excludes in pom


When I have tables in and columns in . Somehow its excluding all columns. My requirement is to create pojo for only 5 tables so included them in at the same time I want only few columns from these tables so have added the columnx in for the ones not needed. But as a result all columns are getting excluded. Here is the code snippet

                    <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>8.0.33</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <jdbc>
                            <driver>${spring.datasource.driver-class-name}</driver>
                            <url>${spring.datasource.url}</url>
                            <username>${spring.datasource.username}</username>
                            <password>${spring.datasource.password}</password>
                        </jdbc>
                        <generator>
                            <generate>
                                <javaTimeTypes>true</javaTimeTypes>
                            </generate>
                            <database>
                                <includes>cart
                                    | material_item
                                    | size_item
                                    | ACCOUNTSALESORG__C
                                    | SALESORG__C
                                    | CONTACT
                                    | USER
                                </includes>
                                <includeExcludeColumns>true</includeExcludeColumns>                                 
                                <excludes>.*\.ACCOUNTSALESORG__C.CREATEDBYID
                                    | .*\.ACCOUNTSALESORG__C.LASTMODIFIEDBYID                                       
                                </excludes>
                                <schemata>
                                    <schema>
                                        <inputSchema>business_new</inputSchema>
                                    </schema>
                                    <schema>
                                        <inputSchema>orchestration_new</inputSchema>
                                    </schema>
                                </schemata>
                            </database>
                            <target>
                                <packageName>com.b2b.adidas.sfmc.search.db</packageName>
                                <directory>src/main/java</directory>

Solution

  • When you specify includeExcludeColumns, then your includes and excludes will have to match both tables and/or columns. The way it looks now you're matching (including) only tables, so the columns will not be included. Do this instead:

    <includes>
    # Table part
    (  
      cart
    | material_item
    | size_item
    | ACCOUNTSALESORG__C
    | SALESORG__C
    | CONTACT
    | USER
    )
    
    # Column part
    (\..*)?
    </includes>
    

    This appears to have been confusing time and again, I'll see that it will be better documented: https://github.com/jOOQ/jOOQ/issues/16916