【发布时间】:2021-02-02 10:17:39
【问题描述】:
我在数据库中有我的 json 列作为 jsonb 对象,我的 ORM 映射具有以下内容
@Column(name = "response_json")
@ColumnTransformer(write = "?::jsonb")
private String responseJson;
当我尝试使用 saveOrUpdate() 写入数据库时
myDao.updateJsonByTxId(i, myJson.toString());
我正在将作为 JSONObject 的 myJson 转换为字符串,但出现以下错误
Caused by: org.postgresql.util.PSQLException: ERROR: column "response_json" is of type jsonb but
expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 48
Json 字符串肯定是有效的 json,不知道是什么问题
【问题讨论】:
标签: java spring postgresql hibernate orm