记录MyBatis text类型 查询 更新 数据是null

数据库表里面存在text或者blob字段。逆向工程自动生成的MyBatis的xml中会多出几个以withBlobs结尾的方法和resultMap

此时查询数据或者更新数据的使用仍然使用selectByPrimaryKey或者updateByPrimaryKey,得到的text或者blob数据是null。

解决办法:

应该使用selectByExampleWithBLOBs或者updateByExampleWithBLOBs这两个方法。

使用text或者blob字段 要单独定义 resultMap     继承 原来的resultMap

<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.aosmith.iot.entity.Permission">
  <result column="permission_info" jdbcType="VARCHAR" property="permissionInfo"/>
</resultMap>

古人学问无遗力,少壮工夫老始成。 纸上得来终觉浅,绝知此事要躬行。
原文地址:https://www.cnblogs.com/wf-zhang/p/12027348.html