在学习中遇到了这样的问题就是,当查询语句是动态变化的时候例如<select id="getValue" parameterXClass="java.lang.String" resultClass="java.util.HashMap"><![CDATA[select $str$ from student where $con_str$]]></select>时服务器启动后,前台前后不同次传过来的参数不同的时,后来传进去的参数虽然在log4j里面可以打印出来的sql语句是正确的,但是得到的结果永远都是对应第一次传进去的参数,这就是ibatis的缓存机制问题,而且如果在第一传的参数基础上删减,后台会报:check the result mapping for the'xx' property;
cause :java.sql.SQLException:Column'xx' not found;解决办法就是:在动态查询语句的后面加 remapResults="true" 例如<select id="getValue" parameterXClass="java.lang.String" resultClass="java.util.HashMap" remapResults="true">就可以取出动态缓存啦 :D
cause :java.sql.SQLException:Column'xx' not found;解决办法就是:在动态查询语句的后面加 remapResults="true" 例如<select id="getValue" parameterXClass="java.lang.String" resultClass="java.util.HashMap" remapResults="true">就可以取出动态缓存啦 :D
本文介绍了一个在使用IBATIS框架时遇到的问题,即动态SQL语句导致的缓存机制问题。文中详细解释了问题的现象,并提供了解决方案——通过添加remapResults属性来正确获取动态查询结果。
437

被折叠的 条评论
为什么被折叠?



