duanbt / mybatis-dbfield-encrypt

mybatis 字段加解密插件,兼容mybatis-plus的wrapper,支持对Map等非pojo对象的加解密,支持不同字段使用不同算法或密钥
9 stars 4 forks source link

Mapper里如果存在同名函数会导致找不到参数的报错 #1

Open waynesun01 opened 9 months ago

waynesun01 commented 9 months ago

xml里定义了一个queryList,在mapper中定义了两个同名方法:

    IPage<MerchVO> queryList(Page page, @Param(Constants.WRAPPER) QueryWrapper<MerchEntity> wrapper);
    List<MerchVO> queryList(@Param(Constants.WRAPPER) QueryWrapper<MerchEntity> wrapper);

当调用Listlist=this.basemapper.queryList(wrapper)时会报错 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'arg0' not found. Available parameters are [ew, param1] 经过调试,发现是CryptManager.getMethodByMappedStatementId里只缓存了第一个queryList 现在只能改第一个方法名为queryPage,然后xml再复制一遍queryList

duanbt commented 9 months ago

xml里定义了一个queryList,在mapper中定义了两个同名方法:

  IPage<MerchVO> queryList(Page page, @Param(Constants.WRAPPER) QueryWrapper<MerchEntity> wrapper);
  List<MerchVO> queryList(@Param(Constants.WRAPPER) QueryWrapper<MerchEntity> wrapper);

当调用Listlist=this.basemapper.queryList(wrapper)时会报错 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'arg0' not found. Available parameters are [ew, param1] 经过调试,发现是CryptManager.getMethodByMappedStatementId里只缓存了第一个queryList 现在只能改第一个方法名为queryPage,然后xml再复制一遍queryList

@waynesun01 经本地复现,确实是存在这个问题。另外CryptManager 类中有4个cache以MappedStatement.Id作为key,如果在mapper中有重载方法时,还可能会引发其他的问题。目前我这还没有想到比较好的解决办法,请问你有什么思路吗?

另外,你已经在项目中使用这个框架了吗?

duanbt commented 9 months ago

MappedStatement.id = Mapper的全类名+'.'+方法名,原生mybatis环境下也不支持mapper方法重载,这么看来这个问题其实可以不用解决。

参考:https://blog.csdn.net/qq_36535538/article/details/122995079