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

《MyBatis 从入门到精通》23页第1点,没有问题 #14

Open
abel533 opened this issue Jul 20, 2017 · 1 comment
Open

《MyBatis 从入门到精通》23页第1点,没有问题 #14

abel533 opened this issue Jul 20, 2017 · 1 comment

Comments

@abel533
Copy link
Contributor

abel533 commented Jul 20, 2017

书中内容如下:

1

好多人都认为“如果存在,才应该抛出异常”。

为什么是存在才会抛出异常

MyBatis 这种策略是为了防止同一个命名空间(所在的接口或者XML)配置多次导致重复读取。所以如果存在,就说明已经读取过了,不能再次读取。这里的逻辑是没有问题的。

验证的方法很简单,就是将同一个mapper配置两次就能看到效果。

@Noodles-Buddy
Copy link

我个人认为,这里之所以会有“很多人”抛出这个问题,原因是这里确实很容易让人产生歧义,“如果对应的命名空间已经存在”,应该是“对应的命名空间已经被配置过”,这样子会更加严谨。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants