首页 > 其他 > 详细

MyBatis中selectByExample和selectByExampleWithBLOBs区别

时间:2018-11-29 17:42:55      阅读:487      评论:0      收藏:0      [点我收藏+]
MyBatis中selectByExample和selectByExampleWithBLOBs区别

先贴一段自动生成的Mapper代码

  <select id="selectByExample" parameterType="com.pojo.TbItemParamExample" resultMap="BaseResultMap">
<select id="selectByExampleWithBLOBs" parameterType="com.pojo.TbItemParamExample" resultMap="ResultMapWithBLOBs">

到这里发现他们的返回值不同。

<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>

可以看出selectByExampleWithBLOBs的返回值ResultMapWithBLOBs是继承自selectByExample的返回值BaseResultMap,他拥有BaseResultMap的全部属性,并且拥有自己特有的属性param_data,而数据库param_data的类型为text,text的最大长度约为64KB,所以要使用blob。

技术分享图片


数据库有四种text,分别对应四种blob。
TinyBlob 最大长度255个字元(2^8-1) ==>255
TinyText 最大长度255个字元(2^8-1)
Blob 最大长度65535个字元(2^16-1) ==>64KB
Text 最大长度65535个字元(2^16-1)
MediumBlob 最大长度 16777215 个字元(2^24-1) ==>16MB
MediumText 最大长度 16777215 个字元(2^24-1)
LongBlob 最大长度4294967295个字元 (2^32-1) ==>4GB
LongText 最大长度4294967295个字元 (2^32-1)

参考自:

https://www.cnblogs.com/pureEve/p/6015000.html
https://www.jianshu.com/p/492ffd296a74?utm_campaign

MyBatis中selectByExample和selectByExampleWithBLOBs区别

原文:http://blog.51cto.com/12434484/2323778

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!