Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

处理通用方法出现IncompleteElementException #876

Open
caippppppppppp opened this issue Feb 16, 2023 · 2 comments
Open

处理通用方法出现IncompleteElementException #876

caippppppppppp opened this issue Feb 16, 2023 · 2 comments
Labels

Comments

@caippppppppppp
Copy link

caippppppppppp commented Feb 16, 2023

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

@abel533 abel533 added the bug label Feb 16, 2023
@abel533 abel533 pinned this issue Feb 16, 2023
@caippppppppppp
Copy link
Author

caippppppppppp commented Feb 17, 2023

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
            }
        }

@abel533
Copy link
Owner

abel533 commented Jun 1, 2023

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

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

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

@abel533 abel533 unpinned this issue Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants