
mybatis 版本:3.2.7/3.2.8
刚开始登录查询时是走的数据库,但是到后面,返回的数据全是之前的查询数据,查资料说把缓存关闭,但是没效果。
还有一个线程是专门在定时查询数据库中数据的,也出现类似情况,但是每次获取新的sqlsession查询数据可以获取数据库的数据,如果用一个sqlsession则不会走数据库,全是缓存的数据。
------------------------------------------
mapper上加注解没用
@Options(flushCache = true )
List<User> selectByExample(UserExample example);
xml文件加 flushCache="true" 也没用
<select id="selectByExample" resultMap="BaseResultMap" flushCache="true" parameterType="com.coopll.springmvc.pojo.UserExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from user
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>