如果数据库中的字段为text或者blob这种大文本类型,在使用MybatisGenerator工具自动生成代码的时候会将其进行特殊处理(一个新的sql片段),结果会导致无法对该字段的值进行操作。
解决方式:
修改generatorConfig.xml配置文件,其中column为你需要覆盖的数据库字段
<table tableName="dynamic" domainObjectName="Dynamic">
<columnOverride column="content_info" jdbcType="VARCHAR" />
<columnOverride column="content" jdbcType="VARCHAR" />
<columnOverride column="dynamic_data" jdbcType="VARCHAR" />
</table>
其他配置
<!-- 是否生成注释代时间戳-->
<commentGenerator><property name="suppressDate" value="true"/>
<!-- 是否取消注释 -->
<property name="suppressAllComments" value="true"/>