当前使用版本(必填,否则不予处理)
3.5.1
该问题是如何引起的?(确定最新版也有问题再提!!!)
@TableField(typeHandler = ImagesInfoHandler.class)
private List<ImagesInfo> imagesInfo;
@TableField(typeHandler = LongArrayTypeHandler.class)
private List<Long> ids;
重现步骤(如果有就写完整)
1.代码实现逻辑
报错信息
执行到错误typeHandle 导致反序列化失败
Comment From: miemieYaho
Comment From: weitangli
试一下这样?
@TableField(typeHandler = JacksonTypeHandler.class)
private ImagesInfo[] imagesInfo;
Comment From: weitangli
你的问题应该是JsonUtil.jsonToObject封装不好导致的。
Comment From: wweiaixingxing
谢谢,这样是可以的,我自己找到问题了,是mybatis 的bug,mybatis 注册 TypeHandlerRegistry 是 应为类型和实例类 都是一样的,所以找错了TypeHandle ,
指定一下这个就可以,但是@MappedTypes({ Long.class}) 就可以,但是又会引起自定义sql 执行是 不能找到对应的TypeHandle
这个bug 根本原因是mybatis 在支持 List
Comment From: weitangli
不是很理解,或者你在自定义查询上使用@ResultMap试试?
例如:
@Mapper
public interface UserMapper extends BaseMapper<User> {
@ResultMap("mybatis-plus_User")
@Select("select ........")
User getByXXX(@Param(Constants.WRAPPER) Wrapper<User> queryWrapper);
}