在mybatis3相同查询条件的SQL语句只查询一次,我想每次都执行查询,mybatis3应该如何实现。
应该是配置了缓存造成的 使用了缓存,去掉缓存
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- namespace和定义的Mapper接口对应,并实现其中的方法 -->
<mapper namespace="com.cst.user.dao.mysql.DepDaoImpl">
<cache></cache> <select id="queryDepList" flushCache="false" useCache="true" resultType="com.cst.user.model.Dep">
select id,name,parentid
from t_dep
</select>
</mapper>我用的是ibatis
只查询一次
你就for循环试一下。
不过我用ibatis上是有全部查询的菜单的。
看下是不是使用缓存里的数据了。mybatis 和ibatis差别有点大 不敢乱说配置文件中cash取消 或者在查询语句中加入usercash=false