雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

myibatis的坑--text类型的字段查询缺失

Posted on 2017-01-13 20:42  huhuuu  阅读(1549)  评论(0编辑  收藏  举报

问题:某个字段的类型为text(或者mediumtext,longtext)的时候,用selectByQuery语句查询出来的结果不包含该字段内容。

 

myibatis 用mybatis-generator自动生成以后,text,mediumtext,longtext跟普通的varchar,char类型的字段会有区别。

如下:

  <resultMap id="BaseResultMap" >
 
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP" />
    <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP" />
 
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" extends="BaseResultMap" >
 
    <result column="job_content" property="jobContent" jdbcType="LONGVARCHAR" />
  </resultMap>

不单单只有“BaseResultMap”,还有一个“ResultMapWithBLOBs”,

后面在查询的时候,有两个select,一个是只包含BaseResultMap的selectByQuery,另外一个是包含BaseResultMap和ResultMapWithBLOBs的selectByQueryWithBLOBs。

 

结论:如果所有内容都想查询,就要用selectByQueryWithBLOBs,默认的selectByQuery会有问题。