selectByExampleWithBLOBs 和selectByExample 的区别

今天使用selectByExample 取数据库中取数据,发现有一个字段始终取不出来,参考文章,通过检查发现该字段是text类型。

将调用selectByExample方法改为调用selectByExampleWithBLOBs 方法就能取出数据。

  <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(bigvarchar),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://blog.csdn.net/u013430054/article/details/82416343 
 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值