mybatis plus updateById更新JSON字段报错
在对应的实体类上添加@TableName(autoResultMap = true)// 或者使用 FastjsonTypeHandler。以及对应的json字段添加注解。
### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
### The error may exist in net/jjjshop/common/mapper/order/OrderRefundMapper.java (best guess)
### The error may involve net.jjjshop.common.mapper.order.OrderRefundMapper.updateById-Inline
### The error occurred while setting parameters
### SQL: UPDATE jjjfood_order_refund SET order_id = ?, order_no = ?, pay_type = ?, pay_price = ?, refund_type = ?, poundage = ?, refund_money = ?, refund_status = ?, refund_detail = ?, shop_supplier_id = ? WHERE app_id = 10001 AND id = ?
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
; Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
解决方法:
在对应的实体类上添加@TableName(autoResultMap = true)
以及对应的json字段添加注解
@TableField(typeHandler = JacksonTypeHandler.class)
// 或者使用 FastjsonTypeHandler
// @TableField(typeHandler = FastjsonTypeHandler.class)
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)