mybatis查询报错,高难度

mybatis查询使用Map作为test查询条件报错
项目上查询时偶现
<select id="queryRecord" resultType="Map">
    select * from ${tableName}
    <where>
      <if test="keysRecord!=null ">
         <foreach collection="keysRecord.entrySet()" separator="AND" index="k" item="entry">
             <if test="entry.value != null and entry.value != ''" >
                ${entry.key} = #{entry.value}
             if>
          foreach>
      if>
    where>    
  select>


运行结果及详细报错内容

Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'entry.value != null and entry.value != '''. Cause: org.apache.ibatis.ognl.OgnlException: value [java.lang.IllegalAccessException: Class org.apache.ibatis.ognl.OgnlRuntime can not access a member of class java.util.HashMap$Entry with modifiers "public final"]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)

我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%

猜测就是Map中entry.value值拿不到,拿不到里面报了权限不允许访问错误。想不明白为何会拿不到权限,是mybatis的这个test表达式使用反射导致的问题吗

这个问题是由于foreach不支持entry.value != null和entry.value != ''这种条件判断方式引起的,可以修改test条件:

${entry.key} = #{entry.value}