Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen case sensivity #16570

Open
Jouda-Hidri opened this issue Apr 20, 2024 · 4 comments
Open

Codegen case sensivity #16570

Jouda-Hidri opened this issue Apr 20, 2024 · 4 comments

Comments

@Jouda-Hidri
Copy link

Your question

I upgraded a project from

  • Java 11 -> Java 21,
  • H2 1.4.194 -> 2.2.224
  • Flyway 8 -> 10.

The entities generated in Java, used to be generated with DSL names in lower_case. After upgrade, it became UPPER_CASE. I had to change the setup of H2 to generate tables in lower_case. But I didnt understand what changed in JOOQ code-gen so that I needed to change this config

jOOQ Version

3.19.3

Database product and version

H2 2.2.224

Java Version

openJDK21

JDBC / R2DBC driver name and version (include name if unofficial driver)

No response

@lukaseder
Copy link
Member

Thanks for your message. I'm assuming this question is also yours?

Can you please show your complete code generation configuration?

@Jouda-Hidri
Copy link
Author

Jouda-Hidri commented Apr 22, 2024

project.flyway {
            user = project.rootProject.name
            url = "jdbc:h2:file:${buildDir}/generated/h2/${project.rootProject.name};mode=MySQL;DATABASE_TO_LOWER=TRUE"
            driver = 'org.h2.Driver'
        }
        project.dependencies {
            jooqGenerator 'com.h2database:h2:2.2.224'
        }

        project.jooq {
            version = '3.19.3'
            configurations {
                main {
                    generationTool {
                        jdbc {
                            driver = 'org.h2.Driver'
                            url = project.flyway.url
                            user = project.flyway.user
                        }
                        generator {
                            database {
                                inputSchema = 'public'
                            }
                            target {
                                packageName = project.rootProject.group + '.' + project.name.replaceAll('[-_]', '') + '.jooq'
                                directory = "${buildDir}/generated/source/jooq/main"
                            }
                            generate {
                                javaTimeTypes = false
                            }
                        }
                        logging = 'DEBUG'
                    }
                }
            }
        }

@lukaseder
Copy link
Member

I wonder, is this really a problem caused by jOOQ instead of by your H2 upgrade? I don't see why jOOQ would produce such a change on its own. Does your H2 database produce lower case identifiers when you connect to it (e.g. using Dbeaver) and query the INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS views?

Please note that rather than using H2 to generate code, why not work with testcontainers and an actual MySQL instance. That would also allow you to use vendor specific features not supported by H2's mode=MySQL mode:
https://blog.jooq.org/using-testcontainers-to-generate-jooq-code/

@Jouda-Hidri
Copy link
Author

Jouda-Hidri commented May 3, 2024

Per default H2 tables, columns and schema are UPPER_CASE. I had to change the config for H2 to lower_case and then the schema from 'PUBLIC' to 'public' for JOOQ code-gen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants