【发布时间】:2020-05-22 16:30:14
【问题描述】:
我正在尝试用 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列时如何解决这个错误?
【问题讨论】:
标签: postgresql spring-boot mybatis spring-mybatis