First, paste an automatically generated Mapper code
<select id="selectByExample" parameterType="com.pojo.TbItemParamExample" resultMap="BaseResultMap">
<select id="selectByExampleWithBLOBs" parameterType="com.pojo.TbItemParamExample" resultMap="ResultMapWithBLOBs">
Here we find that their return values are different.
<resultMap id="BaseResultMap" type="com.pojo.TbItemParam"> <!-- WARNING - @mbg.generated This element is automatically generated by MyBatis Generator, do not modify. This element was generated on Mon Aug 27 16:29:38 CST 2018. --> <id column="id" jdbcType="BIGINT" property="id" /> <result column="item_cat_id" jdbcType="BIGINT" property="itemCatId" /> <result column="created" jdbcType="TIMESTAMP" property="created" /> <result column="updated" jdbcType="TIMESTAMP" property="updated" /> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.pojo.TbItemParam"> <!-- WARNING - @mbg.generated This element is automatically generated by MyBatis Generator, do not modify. This element was generated on Mon Aug 27 16:29:38 CST 2018. --> <result column="param_data" jdbcType="LONGVARCHAR" property="paramData" /> </resultMap>
It can be seen that the return value ResultMapWithBLOBs of selectByExampleWithBLOBs is inherited from the return value BaseResultMap of selectByExample. It has all the properties of BaseResultMap and its own unique property param_data. The type of database param_data is text, and the maximum length of text is about 64KB, so blob should be used.
There are four kinds of text in the database, corresponding to four kinds of blob s.
The maximum length of TinyBlob is 255 characters (2 ^ 8-1) = > 255
TinyText maximum length 255 characters (2 ^ 8-1)
Blob maximum length 65535 characters (2 ^ 16-1) = > 64KB
Text maximum length 65535 characters (2 ^ 16-1)
The maximum length of MediumBlob is 16777215 characters (2 ^ 24-1) = > 16MB
Mediamtext maximum length 16777215 characters (2 ^ 24-1)
LongBlob maximum length 4294967295 characters (2 ^ 32-1) = > 4GB
LongText maximum length 4294967295 characters (2 ^ 32-1)
Reference:
https://www.cnblogs.com/pureEve/p/6015000.html
https://www.jianshu.com/p/492ffd296a74?utm_campaign