我正在尝试使用 mybatis 更新 java 中的 jsonb 列。
以下是我的映射器方法
@Update("update service_user_assn set external_group = external_group || '{\"service_name\": \"#{service_name}\" }' where user=#{user} " +
" and service_name= (select service_name from services where service_name='Google') " )
public int update(@Param("service_name")String service_name,@Param("user") Integer user);
更新 jsonb (external_group) cloumn 时出现以下错误。
### Error updating database. Cause: org.postgresql.util.PSQLException: The column index is out of range: 2, number of columns: 1.
### The error may involve com.apds.mybatis.mapper.ServiceUserMapper.update-Inline
对于非 jsonb 列,我可以使用相同的方式进行更新。
此外,如果我输入硬编码值,它适用于 jsonb 列。
更新 jsonb 列时如何解决此错误?