简体   繁体   English

Jooq 3.9没有将MySQL列链接到枚举

[英]Jooq 3.9 doesn't link MySQL columns to enums

I am updating jooq from version 3.4.1 to 3.9.3 and noticed that models for tables that have enum fields in MySQL 5.6 database are generated with String type instead. 我正在将jooq从版本3.4.1更新到3.9.3,并注意到在MySQL 5.6数据库中具有enum字段的表的模型是使用String类型生成的。

The enum corresponding to the field is properly generated, it's just not linked to the pojo corresponding to the table. 对应于该字段的枚举是正确生成的,它只是没有链接到与该表对应的pojo。

CREATE TABLE foo (
  bar ENUM('BarBar') NOT NULL
}

This is an example of generated Pojo for the table Foo : 这是为表Foo生成Pojo的示例:

@Generated(
    value = {
        "http://www.jooq.org",
        "jOOQ version:3.9.0"
    },
    comments = "This class is generated by jOOQ"
)
public class Foo {
    private String bar;
}

and the enum which is not linked to the table pojo, although in its name contains Foo prefix of the table: 链接到表pojo的枚举,虽然在其名称中包含表的Foo前缀:

@Generated(
    value = {
        "http://www.jooq.org",
        "jOOQ version:3.9.0"
    },
    comments = "This class is generated by jOOQ"
)
public enum FooBar implements EnumType {

    BarBar("BarBar");

    private final String literal;

    // ...
}

I haven't changed any configuration, just jooq version. 我没有改变任何配置,只是jooq版本。 I would like to know if this is a bug or most likely some piece of configuration missing on my side. 我想知道这是一个错误,还是很可能是我身边缺少一些配置。

This change was introduced between versions 3.8.8 and 3.9.0 but i haven't been able to narrow it down from release notes. 此更改是在版本3.8.83.9.0之间引入的,但我无法从发行说明中缩小范围。

There is an issue that sort of corresponds to this but it shouldn't have went live, so it's possibly outdated configuration on my part. 有一个问题对应于此但它不应该上线,所以它可能是我过时的配置。

There are two reasons why this could happen: 有两种原因可能导致这种情况发生:

A bug in jOOQ related to <outputSchemaToDefault/> jOOQ中与<outputSchemaToDefault/>相关的错误

This looks like bugs 这看起来像错误

  • #6367 - PostgreSQL enums aren't linked correctly from generated tables when <outputSchemaToDefault/> is true #6367 - 当<outputSchemaToDefault/>为true时,PostgreSQL枚举无法从生成的表中正确链接
  • #6395 - Definition.getQualifiedName() is wrong when <outputSchemaToDefault/> is set to true #6395 - 当<outputSchemaToDefault/>设置为true时,Definition.getQualifiedName()错误

Which will be fixed in jOOQ 3.10.0, 3.9.4, 3.8.8. 这将在jOOQ 3.10.0,3.9.4,3.8.8中修复。 The issue is related to setting the <outputSchemaToDefault/> flag to true. 该问题与将<outputSchemaToDefault/>标志设置为true有关。

You're excluding the enum type with your configuration 您将使用您的配置排除枚举类型

The <includes/> and <excludes/> configuration must ensure that the enum type is included as code generation output. <includes/><excludes/>配置必须确保包含枚举类型作为代码生成输出。 The enum type is a synthetic type that behaves like a PostgreSQL enum type. 枚举类型是一种合成类型,其行为类似于PostgreSQL枚举类型。 It has a synthetic name that is made from: [TABLE_NAME]_[COLUMN_NAME] . 它的合成名称来自: [TABLE_NAME]_[COLUMN_NAME]

Note: In your case, I'm assuming this is done correctly, because you're getting the enum type itself. 注意:在你的情况下,我假设这是正确完成的,因为你自己获得了枚举类型。 I'm adding this here for completeness' sake, in case someone else has similar issues. 我在这里添加这个是为了完整性,以防其他人有类似的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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