Index: org/apache/ibatis/binding/MapperMethod.java =================================================================== --- org/apache/ibatis/binding/MapperMethod.java (revision 881803) +++ org/apache/ibatis/binding/MapperMethod.java (working copy) @@ -29,13 +29,15 @@ private Integer rowBoundsIndex; private List paramNames; private List paramPositions; - - public MapperMethod(Method method, SqlSession sqlSession) { + private Class interfaceClass; + + public MapperMethod(Method method, Class interfaceClass,SqlSession sqlSession) { paramNames = new ArrayList(); paramPositions = new ArrayList(); this.sqlSession = sqlSession; this.method = method; this.config = sqlSession.getConfiguration(); + this.interfaceClass=interfaceClass; setupFields(); setupMethodSignature(); setupCommandType(); @@ -97,7 +99,7 @@ // Setup // private void setupFields() { - this.commandName = method.getDeclaringClass().getName() + "." + method.getName(); + this.commandName = interfaceClass.getName() + "." + method.getName(); } private void setupMethodSignature() { Index: org/apache/ibatis/binding/MapperProxy.java =================================================================== --- org/apache/ibatis/binding/MapperProxy.java (revision 881803) +++ org/apache/ibatis/binding/MapperProxy.java (working copy) @@ -15,7 +15,23 @@ } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return new MapperMethod(method, sqlSession).execute(args); + Class interfaceClass = null; + //find the interface that actually has the method + //this could fail if the proxy implements multiple interfaces with the given method + //but I think that is easily avoided + for (Class iface : proxy.getClass().getInterfaces()) { + try { + Method m = iface.getMethod(method.getName(), method.getParameterTypes()); + interfaceClass = iface; + break; + } catch (Exception e) { + + } + } + if (interfaceClass==null) { + throw new RuntimeException("Could not find interface with the given method "+method); + } + return new MapperMethod(method, interfaceClass,sqlSession).execute(args); } public static T newMapperProxy(Class mapperInterface, SqlSession sqlSession) { Index: org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java =================================================================== --- org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java (revision 881803) +++ org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java (working copy) @@ -164,7 +164,7 @@ SqlSource sqlSource = getSqlSourceFromAnnotations(method); if (sqlSource != null) { Options options = method.getAnnotation(Options.class); - final String mappedStatementId = method.getDeclaringClass().getName() + "." + method.getName(); + final String mappedStatementId = type.getName() + "." + method.getName(); boolean flushCache = false; boolean useCache = true; Integer fetchSize = null;