MyBatis中如果某个查询不希望使用缓存,可以在映射文件中的select语句上设置flushCache="true"属性
<select id="xmlGetGuaranteeCount" databaseId="sqlserver" resultType="Integer" flushCache="true"> <![CDATA[ SELECT count(appisparea.ID) FROM T_APP_ISP_AREA AS appisparea WHERE 1=1 ]]> <if test="ispDataId != null and ispDataId != '' " > <![CDATA[ AND FK_ISP_DATAID = #{ispDataId} ]]> </if> <if test="beiAnDiQuCode != null and beiAnDiQuCode=='000000' " > <![CDATA[ AND BEIANDIQU_CODE NOT LIKE 'x%' ]]> </if> <if test="beiAnDiQuCode != null and beiAnDiQuCode.toLowerCase().startsWith('x') " > <![CDATA[ AND BEIANDIQU_CODE = #{beiAnDiQuCode} ]]> </if> </select>
吾乃代码搬运工,侵联删