简体   繁体   English

JOOQ 在获取表元数据时抛出 DataTypeException

[英]JOOQ throws DataTypeException when fetching table meta

Getting an error when trying to fetch table meta data.尝试获取表元数据时出错。

Using: JOOQ 3.14.0, PostgeSQL 12, PostgreSQL driver 42.2.10使用:JOOQ 3.14.0、PostgeSQL 12、PostgreSQL 驱动程序 42.2.10

Example:例子:

@RestController
@ApiVersion("v2")
public class TypeResource {
    private final DSLContext ctx;

    @GetMapping(value = "/test")
    public void test(@RequestParam String table) {
        ctx.meta().getTables(table);
    }
}

Error (This is not the whole error but the rest is similar):错误(这不是整个错误,但其余类似):

17:16:44.808 [http-nio-8181-exec-5] [WARN ] org.jooq.impl.MetaImpl - Default value            : Could not load default value: '{}'::character varying[] for type: varchar ([Ljava.lang.String;)
org.jooq.exception.DataTypeException: Cannot convert from '{}'::character varying[] (class java.lang.String) to class [Ljava.lang.String;
    at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1303)
    at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1192)
    at org.jooq.tools.Convert.convert0(Convert.java:392)
    at org.jooq.tools.Convert.convert(Convert.java:384)
    at org.jooq.tools.Convert.convert(Convert.java:458)
    at org.jooq.impl.AbstractDataType.convert(AbstractDataType.java:534)
    at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:86)
    at org.jooq.impl.DSL.val(DSL.java:24373)
    at org.jooq.impl.DSL.inline(DSL.java:23891)
    at org.jooq.impl.MetaImpl$MetaTable.init(MetaImpl.java:910)
    at org.jooq.impl.MetaImpl$MetaTable.<init>(MetaImpl.java:560)
    at org.jooq.impl.MetaImpl$MetaSchema.getTables(MetaImpl.java:421)
    at org.jooq.impl.MetaImpl.getTables0(MetaImpl.java:217)
    at org.jooq.impl.AbstractMeta$4.iterator(AbstractMeta.java:194)
    at org.jooq.impl.AbstractMeta.get(AbstractMeta.java:340)
    at org.jooq.impl.AbstractMeta.initTables(AbstractMeta.java:191)
    at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:172)
    at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:167)
17:16:44.843 [http-nio-8181-exec-5] [WARN ] org.jooq.impl.MetaImpl - Default value            : Could not load default value: '{{0,0}}'::numeric[] for type: numeric ([Ljava.math.BigDecimal;)
org.jooq.exception.DataTypeException: Cannot convert from '{{0,0}}'::numeric[] (class java.lang.String) to class [Ljava.math.BigDecimal;
    at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1303)
    at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1192)
    at org.jooq.tools.Convert.convert0(Convert.java:392)
    at org.jooq.tools.Convert.convert(Convert.java:384)
    at org.jooq.tools.Convert.convert(Convert.java:458)
    at org.jooq.impl.AbstractDataType.convert(AbstractDataType.java:534)
    at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:86)
    at org.jooq.impl.DSL.val(DSL.java:24373)
    at org.jooq.impl.DSL.inline(DSL.java:23891)
    at org.jooq.impl.MetaImpl$MetaTable.init(MetaImpl.java:910)
    at org.jooq.impl.MetaImpl$MetaTable.<init>(MetaImpl.java:560)
    at org.jooq.impl.MetaImpl$MetaSchema.getTables(MetaImpl.java:421)
    at org.jooq.impl.MetaImpl.getTables0(MetaImpl.java:217)
    at org.jooq.impl.AbstractMeta$4.iterator(AbstractMeta.java:194)
    at org.jooq.impl.AbstractMeta.get(AbstractMeta.java:340)
    at org.jooq.impl.AbstractMeta.initTables(AbstractMeta.java:191)
    at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:172)
    at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:167)
    

Example table create script :示例表创建脚本:

CREATE TABLE public.user_role
(
    id bigint NOT NULL DEFAULT nextval('user_role_id_seq'::regclass),
    user_id bigint NOT NULL,
    role_id bigint NOT NULL,
    ts_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
    ts_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_by_user character varying(256) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
    updated_by_process character varying(64) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
    CONSTRAINT user_role_pkey PRIMARY KEY (id),
    CONSTRAINT x_role_id_fk FOREIGN KEY (role_id)
        REFERENCES public.role (id) MATCH FULL
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT x_user_id_fk FOREIGN KEY (user_id)
        REFERENCES public."user" (id) MATCH FULL
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE public.user_role
    OWNER to postgres;

CREATE UNIQUE INDEX x_role_user_id_role_id_uq
    ON public.user_role USING btree
    (user_id ASC NULLS LAST, role_id ASC NULLS LAST)
    TABLESPACE pg_default;

Initially my goal was to get the table indexes and this is working fine.最初我的目标是获取表索引,这工作正常。 I tried to update JOOQ from 3.13.1 to 3.14.0 and tested with different tables in the database but without any luck.我尝试将 JOOQ 从 3.13.1 更新到 3.14.0 并使用数据库中的不同表进行测试,但没有任何运气。

This is a bug which will be fixed in jOOQ 3.15 via https://github.com/jOOQ/jOOQ/issues/8469 .这是一个错误,将通过https://github.com/jOOQ/jOOQ/issues/8469在 jOOQ 3.15 中修复。 jOOQ currently assumes that DatabaseMetaData column descriptions produce values for DEFAULT expressions, instead of expressions. jOOQ 当前假设DatabaseMetaData列描述为DEFAULT表达式而不是表达式生成值。

The bug is "cosmetic", as it only affects your logs.该错误是“装饰性的”,因为它只会影响您的日志。 The field is still produced correctly (without any DEFAULT expression).该字段仍然正确生成(没有任何DEFAULT表达式)。 You can mute the message in your logger configuration until the above bug is fixed.您可以在记录器配置中静音消息,直到上述错误得到修复。

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

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