MyBatis version

3.5.1

Database vendor and version

mysql 5.1.38

Test case or example project

dp.zip

Steps to reproduce

first unzip the zip file(dp.zip) secondly. import this project by IDEA lastly: run the test cases in Test class(method called test)

Expected result test case in Test class

[ com.spring.EmpMapper.update, update]

Actual result

[com.spring.StudentMapper.update, com.spring.EmpMapper.update, update]

Comment From: kazuki43zoo

Hi @guanjunlinger ,

I cannot understand your expected result. I think there is no problem in this case. Could you explain more details about problem?

Comment From: guanjunlinger

re details about

I thinks, when sub Mapper interface extends super Mapper interface ,Sub Mapper Interface must not register a MappedStatement Object which will be registered by Super Mapper Interface. because of the strategy of searching MappedStatement Object(which can searched from current Interface to super Interface )

Comment From: harawata

It is a 'feature' and is very important to achieve the 'common mapper' strategy like #321 .

Comment From: guanjunlinger

It is a 'feature' and is very important to achieve the 'common mapper' strategy like #321 . maybe you misunderstand me .As you say,It's a feature which can be used in generic base interface,then only register concrete sub interface. I just describe the situation which parent mapper interface and sub mapper interface both is a concrete interface, have no generic parameter.in this case, they are both be redistered by addMapper method, which results in super interface method be redistered twice.

Comment From: harawata

Um...MyBatis does not register super interface's method twice. MyBatis registers 1) super interface's update method and 2) child interface's update method which is inherited from the parent.

I'm sorry if it is different from what you expect, but it is just how it works and there is no way we can change that behavior.

Comment From: guanjunlinger

so,super interface's method should by register second times.Maybe I should give you some source code

Comment From: harawata

@guanjunlinger , If you are experiencing some problem (like an exception or unexpected query result) caused by this behavior, please create a demo that reproduces the problem.

Comment From: guanjunlinger

Method[] methods = type.getMethods(); for (Method method : methods) { try { // issue #237 if (!method.isBridge()) { parseStatement(method); } } catch (IncompleteElementException e) { configuration.addIncompleteMethod(new MethodResolver(this, method)); } } } as you see,when you call addMapper method on super Interface and sub interface at the same time, two same mappedStatement object will be created ,which just id has difference because of key creation rules(class name+method name).I think this behavior wasted space because we just only a mappedStatement object which can be shared among parent interface and sub interface

Comment From: guanjunlinger

test cases I have submited the first time.but seems you don't understand my means

Comment From: harawata

I'm sorry about my misunderstanding. I thought this was a bug report, but it actually was a proposal (right?).

Now, your example is not realistic enough for us to understand the advantage of your proposal. Please explain why you have to register so many child interfaces which have the same SQLs as parent.

Also, this seems a little bit like micro-optimization, so you need to show us it is not. Have you done any measurement? i.e. How much memory does the current implementation 'waste'?

Comment From: harawata

No reply.