一、問題復現:
通過selectByExample查詢planJonsData時值爲null,但通過selectByExampleWithBLOBs不改變查詢條件,查詢的結果值不爲空
二、selectByExampleWithBLOBs與selectByExample的區別
對比兩個查詢方法,不難發現selectByExampleWithBLOBs 除了具有selectByExample的屬性,在resultMap 裏還額外定義一行 jdbcType=“LONGVARCHAR”,用於長文本查詢,所以當數據表中有text等存儲長文本類型時,最好在查詢、更新時能使用帶WithBLOBs結尾的方法,另外selectByPrimaryKey的resultMap也帶有WithBLOBs。
<resultMap id="BaseResultMap" type="com.xxx.CooperationModel">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
...
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.xxx.CooperationModel">
<result column="plan_json_data" jdbcType="LONGVARCHAR" property="planJsonData" />
</resultMap>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">