【发布时间】:2019-09-19 15:52:26
【问题描述】:
我正在尝试让这个查询在 JPA 中工作:
UPDATE billing_log_criteria
SET value = jsonb_set(value, '{cubPersonId}', '"12778269"')
where value ->> 'cubPersonId' = '12778268';
它与 postgresql 完美配合,但是当我将它与 JPA 集成时,我收到以下错误:
原因:org.postgresql.util.PSQLException: ERROR: function jsonb_set(jsonb, unknown, character varying) 不存在 提示:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。
以下是我尝试过的查询
@Modifying(clearAutomatically=false)
@Transactional
@Query(value = "UPDATE billing_log_criteria "
+ "SET value = jsonb_set(value, '{cubPersonId}', jsonb_set(value, '{cubPersonId}', :newId)) "
+ "where value ->> 'cubPersonId' = :oldId", nativeQuery = true)
void updateCubPersonId(@Param("newId") String newId,@Param("oldId") String oldId);
这样打电话
String oldId = "12778269";
updateCubPersonId( "'\" 12778268l \"'",oldId);
【问题讨论】:
标签: json postgresql spring-boot jpa jsonb