{"record":{"id":"ad5f3665c939d78e","repo":"mybatis/mybatis-3","slug":"unknown-execution-method-for-name","errorCode":null,"errorMessage":"Unknown execution method for: {name}","messagePattern":"Unknown execution method for: (.+?)","errorType":"exception","errorClass":"BindingException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/binding/MapperMethod.java","lineNumber":97,"sourceCode":"        } else if (method.returnsMany()) {\n          result = executeForMany(sqlSession, args);\n        } else if (method.returnsMap()) {\n          result = executeForMap(sqlSession, args);\n        } else if (method.returnsCursor()) {\n          result = executeForCursor(sqlSession, args);\n        } else {\n          Object param = method.convertArgsToSqlCommandParam(args);\n          result = sqlSession.selectOne(command.getName(), param);\n          if (method.returnsOptional() && (result == null || !method.getReturnType().equals(result.getClass()))) {\n            result = Optional.ofNullable(result);\n          }\n        }\n        break;\n      case FLUSH:\n        result = sqlSession.flushStatements();\n        break;\n      default:\n        throw new BindingException(\"Unknown execution method for: \" + command.getName());\n    }\n    if (result == null && method.getReturnType().isPrimitive() && !method.returnsVoid()) {\n      throw new BindingException(\"Mapper method '\" + command.getName()\n          + \"' attempted to return null from a method with a primitive return type (\" + method.getReturnType() + \").\");\n    }\n    return result;\n  }\n\n  private Object rowCountResult(int rowCount) {\n    final Object result;\n    if (method.returnsVoid()) {\n      result = null;\n    } else if (Integer.class.equals(method.getReturnType()) || Integer.TYPE.equals(method.getReturnType())) {\n      result = rowCount;\n    } else if (Long.class.equals(method.getReturnType()) || Long.TYPE.equals(method.getReturnType())) {\n      result = (long) rowCount;\n    } else if (Boolean.class.equals(method.getReturnType()) || Boolean.TYPE.equals(method.getReturnType())) {\n      result = rowCount > 0;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/binding/MapperMethod.java#L79-L115","documentation":"Thrown at the default branch of MapperMethod.execute() when the mapped statement's SqlCommandType does not match any of the handled cases (INSERT, UPDATE, DELETE, SELECT, FLUSH). It means MyBatis resolved the statement but its declared command type is something the executor cannot dispatch on. In practice this surfaces as UNKNOWN statement types (e.g. a <sql> fragment misregistered, or custom statement types from Configuration extensions).","triggerScenarios":"Calling a mapper method whose MappedStatement.getSqlCommandType() returns a type outside {INSERT, UPDATE, DELETE, SELECT, FLUSH}; typically a statement parsed with an unknown sqlCommandType attribute or produced by a custom builder.","commonSituations":"Custom Configuration subclasses registering statements with exotic types; corrupted or hand-built MappedStatement objects; edge cases where a statement id collides with a non-executable element.","solutions":["Check the mapper method's matching XML/annotation and confirm the element is one of <insert>, <update>, <delete>, <select>","Verify the statement id used to register the statement matches an executable element, not a <sql> fragment","If using a custom Configuration/builder, ensure it sets a standard SqlCommandType when building MappedStatement"],"exampleFix":"<!-- before -->\n<sql id=\"findById\">SELECT * FROM t WHERE id = #{id}</sql>\n<!-- after -->\n<select id=\"findById\" resultType=\"T\">SELECT * FROM t WHERE id = #{id}</select>","handlingStrategy":"validation","validationCode":"Set<?> execTypes = Set.of(SqlCommandType.INSERT, SqlCommandType.UPDATE, SqlCommandType.DELETE, SqlCommandType.SELECT, SqlCommandType.FLUSH);\nMappedStatement ms = sqlSessionFactory.getConfiguration().getMappedStatement(\"com.example.UserMapper.find\");\nif (!execTypes.contains(ms.getSqlCommandType())) {\n  throw new IllegalStateException(\"Non-executable statement type: \" + ms.getSqlCommandType());\n}","typeGuard":null,"tryCatchPattern":"catch (BindingException e) when starting up: fail configuration fast and log command type; no runtime retry is meaningful.","preventionTips":["Standardize on <select>/<insert>/<update>/<delete> elements only","Run a startup smoke test invoking each mapper method once against a test Configuration"],"tags":["mybatis","binding","mapper","sqlcommand"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}