Mapper icon indicating copy to clipboard operation
Mapper copied to clipboard

处理通用方法出现IncompleteElementException

Open caippppppppppp opened this issue 3 years ago • 2 comments

image processConfiguration 方法 image image image 如果在这过程中加载了其他mapper xml,映射中 resultMap 有extend属性的话,Configuration 类中buildAllStatements是有可能抛出异常的 image

caippppppppppp avatar Feb 16 '23 07:02 caippppppppppp

image

建议通过Class<?> mapperInterface 获取所有方法名,拼接后通过Configuration类 getMappedStatement(String id, boolean validateIncompleteStatements) 获取MappedStatement

Method[] methods = mapperInterface.getMethods();
        for (Method method : methods) {
            try {
                String id = prefix + "." + method.getName();
                processMappedStatement(configuration.getMappedStatement(id, false));
            } catch (Exception e) {
                //ignore
            }
        }

caippppppppppp avatar Feb 17 '23 01:02 caippppppppppp

上面方法没有直接调用的地方,大部分都是:

/**
 * 配置完成后,执行下面的操作
 * <br>处理configuration中全部的MappedStatement
 *
 * @param configuration
 */
public void processConfiguration(Configuration configuration) {
    processConfiguration(configuration, null);
}

参数 mapperInterface 大部分情况都是 null,没法像你这样处理。

abel533 avatar Jun 01 '23 13:06 abel533