gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 08:41:16 25 4
gpt4 key购买 nike

尝试获取表元数据时出错。
使用:
JOOQ 3.14.0,
PostgeSQL 12,
PostgreSQL 驱动程序 42.2.10
例子:

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

@GetMapping(value = "/test")
public void test(@RequestParam String table) {
ctx.meta().getTables(table);
}
}
错误(这不是整个错误,但其余类似):
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)

示例表创建脚本:
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;
最初我的目标是获取表索引,这工作正常。
我尝试将 JOOQ 从 3.13.1 更新到 3.14.0 并使用数据库中的不同表进行测试,但没有任何运气。

最佳答案

这是一个错误,将在 jOOQ 3.15 中通过 https://github.com/jOOQ/jOOQ/issues/8469 修复. jOOQ 当前假设 DatabaseMetaData列描述为 DEFAULT 生成值表达式,而不是表达式。
该错误是“装饰性的”,因为它只会影响您的日志。该字段仍然正确生成(没有任何 DEFAULT 表达式)。您可以在记录器配置中静音消息,直到上述错误得到修复。

关于java - JOOQ 在获取表元数据时抛出 DataTypeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64559122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com