简体   繁体   中英

Jooq Schema Case Sensitivity

I have a case where I am switching between Oracle and MySql using the same schema name. I want to generate classes using either database type and performing operations on the other. Due to case sensitivity issues, I figured out that the approach which accommodates both is to include schema names in lower case (since supported both by Oracle and MySql) and table names and column names in UpperCase (same reason).

However, when declaring the outputShema to lowercase, Jooq explicitly checks the database type, and if it is Oracle, then it is set to UpperCase. Is there any workaround for this?

You've run into a set of unfortunate caveats, which will all be fixed soon. The workaround right now is to use UPPER_CASE schema names in both databases, and configure the code generator to include at least two input schemas. I'll explain:

Oracle and lower_case schema names

Unfortunately, jOOQ currently uses case-insensitive schema name search for historic reasons in Oracle. This leads to a performance issue: https://github.com/jOOQ/jOOQ/issues/5989

And is also incorrect. This is why jOOQ 3.10 will fix this: https://github.com/jOOQ/jOOQ/issues/5990

MySQL and UPPER_CASE schema names

Depending on your OS (eg Windows and MacOS) and on your case sensitivity settings in MySQL, there are some problems with UPPER_CASE schema names. This can lead to trouble in jOOQ's code generator: https://github.com/jOOQ/jOOQ/issues/5213

The issue is fixed for jOOQ 3.10 and will be integrated in 3.9.3. The workaround for this issue is to use more than one input schema in the jOOQ code generator, which will work around this weird MySQL bug: https://bugs.mysql.com/bug.php?id=86022

Summary

A good choice is to use UPPER_CASE everywhere, including your DDL statements:

CREATE TABLE "ORACLE_SCHEMA"."ORACLE_TABLE" AS (
  "ORACLE_COLUMN" VARCHAR2(50)
);

CREATE TABLE `MYSQL_SCHEMA`.`MYSQL_TABLE` AS (
  `MYSQL_COLUMN` VARCHAR(50)
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM