【发布时间】:2018-11-06 18:43:00
【问题描述】:
我尝试存储具有以下约束的尝试对象:
ALTER TABLE ATTEMPT ADD COLUMN files json NOT NULL DEFAULT '{}'::json;
和代码:
AttemptRecord attemptRecord = context.newRecord(T_ATTEMPT, attempt);
setAttemptId(attempt.getId());
store();
但是当我用 Jooq 存储它时,出现以下错误:
nested exception is org.postgresql.util.PSQLException: ERROR: null value in column "files" violates the not-null constraint
在此之前,我有一个 bytearray 列,而不是 json files 列,我在默认值下一切正常。 我也使用调试器工具,AttemptRecord 包含文件的这个值,这对我来说听起来很奇怪,但我不知道这是什么意思。
{NullNode@3189} "null"
如果 JsonNode 为空,它并不真正为空。
为什么 Jooq 忽略默认值?
【问题讨论】:
标签: java postgresql jooq