* * @param statement * @param typeHandlerRegistry MyBatis里typeHandler的注册器,方便转换成用户指定的结果类型 * @param kvTypePair 函数指定返回Map key-value的类型 * @param mapF2FAnnotation * @return * @throws Throwable */ private Object result2Map(Statement statement, TypeHandlerRegistry typeHandlerReg...
在使用MyBatis,我们经常会遇到这种情况:SELECT两个字段,需要返回一个Map,其中第一个字段作为key,第二个字段作为value。MyBatis的MapKey虽然很实用,但并不能解决这种场景。这里,就介绍一种使用拦截器来解决这个问题的方案。 解决方案 2.1 注解 package com.adu.spring_test.mybatis.annotations; import java.lang.anno...