Mybatis+ehcache+存储过程返回List缓存问题
sqlmap.xml:<mapper namespace="SelectCache" >
<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
<resultMap type="User" id="userResultMap">
...
</resultMap>
<!-- call procedure parameter -->
<parameterMap id="parameterMap" type="java.util.HashMap">
<parameter property="IN_TesterCode" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
<parameter property="IN_PassWord" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
<parameter property="result" jdbcType="CURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="userResultMap"/>
</parameterMap>
<select id="getTesterByCodeAndPwd" parameterMap="parameterMap" statementType="CALLABLE" resultType="User">
{call pkg_gettesterbycodeandpwd.proc_gettesterbycodeandpwd(?, ?,?)}
</select>
</mapper>
java code:
List userList = null;
Map<String, Object> param = new HashMap<String, Object>();
param.put("IN_TesterCode", getUser().getTesterCode());
param.put("IN_PassWord", getUser().getPassWord());
param.put("result", userList);
// 调用存储过程
userServices.getTesterByCodeAndPwd(param);
userList= (ArrayList)param.get("result"); // 得到存储过程返回的List
第一次调用userList可用,在缓存没有失效时再次调用,userList为null,郁闷,我知道是缓存的事,但不知道怎么解决,望各位大侠多帮忙,谢谢!!!
--------------------编程问答-------------------- --------------------编程问答-------------------- 帮帮忙啊,千万别沉底了 --------------------编程问答-------------------- List userList = null;
换成
List userList = new ArrayList();
试试、 --------------------编程问答-------------------- 非常感谢,但是换成List userList = new ArrayList();之后userList.size()=0,没有从缓存中取到值,郁闷。希望继续解答,谢谢!!!
补充:Java , Java EE