当前使用版本(必填,否则不予处理)
mybatis-plus-3.4.3.1.jar
重现步骤(如果有就写完整)
entity:
@TableName(value = "`Constraint`", autoResultMap = true)
public class Constraint extends SyncEntityBase {
...
@TableField(jdbcType = JdbcType.VARCHAR, typeHandler = ListFieldDtoTypeHandler.class)
protected List<FieldDto> fields;
...
}
mapper:
public interface ConstraintMapper extends BaseMapper<Constraint> {
}
测试:
Constraint c = constraintService.getById(1L);
constraintMapper.updateById(c); // OK,但无法更新字段为null
constraintMapper.update(null, new UpdateWrapper<Constraint>().eq("id", 1L).set("fields", c.getFields())); //NG
报错信息
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
### The error may exist in deepq/mdm/dao/ConstraintMapper.java (best guess)
### The error may involve deepq.mdm.dao.ConstraintMapper.update-Inline
### The error occurred while setting parameters
### SQL: UPDATE `Constraint` SET fields=? WHERE (id = ?)
### Cause: com.mysql.cj.jdbc.exceptions.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.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.] with root cause
com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
Comment From: miemieYaho
.set("fields", c.getFields(),"typeHandler=xx.xxx.xx.ListFieldDtoTypeHandler")