{"record":{"id":"905d9faf293e532e","repo":"mybatis/mybatis-3","slug":"could-not-find-a-statement-annotation-that-corresp","errorCode":null,"errorMessage":"Could not find a statement annotation that correspond a current database or default statement on method '%s.%s'. Current database id is [%s].","messagePattern":"Could not find a statement annotation that correspond a current database or default statement on method '(.+?)\\.(.+?)'\\. Current database id is \\[(.+?)\\]\\.","errorType":"exception","errorClass":"BuilderException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java","lineNumber":687,"sourceCode":"      Collection<Class<? extends Annotation>> targetTypes) {\n    String databaseId = configuration.getDatabaseId();\n    Map<String, AnnotationWrapper> statementAnnotations = targetTypes.stream()\n        .flatMap(x -> Arrays.stream(method.getAnnotationsByType(x))).map(AnnotationWrapper::new)\n        .collect(Collectors.toMap(AnnotationWrapper::getDatabaseId, x -> x, (existing, duplicate) -> {\n          throw new BuilderException(\n              String.format(\"Detected conflicting annotations '%s' and '%s' on '%s'.\", existing.getAnnotation(),\n                  duplicate.getAnnotation(), method.getDeclaringClass().getName() + \".\" + method.getName()));\n        }));\n    AnnotationWrapper annotationWrapper = null;\n    if (databaseId != null) {\n      annotationWrapper = statementAnnotations.get(databaseId);\n    }\n    if (annotationWrapper == null) {\n      annotationWrapper = statementAnnotations.get(\"\");\n    }\n    if (errorIfNoMatch && annotationWrapper == null && !statementAnnotations.isEmpty()) {\n      // Annotations exist, but there is no matching one for the specified databaseId\n      throw new BuilderException(String.format(\n          \"Could not find a statement annotation that correspond a current database or default statement on method '%s.%s'. Current database id is [%s].\",\n          method.getDeclaringClass().getName(), method.getName(), databaseId));\n    }\n    return Optional.ofNullable(annotationWrapper);\n  }\n\n  public static Class<?> getMethodReturnType(String mapperFqn, String localStatementId) {\n    if (mapperFqn == null || localStatementId == null) {\n      return null;\n    }\n    try {\n      Class<?> mapperClass = Resources.classForName(mapperFqn);\n      for (Method method : mapperClass.getMethods()) {\n        if (method.getName().equals(localStatementId) && canHaveStatement(method)) {\n          return getReturnType(method, mapperClass);\n        }\n      }\n    } catch (ClassNotFoundException e) {","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java#L669-L705","documentation":"Error \"Could not find a statement annotation that correspond a current database or default statement on method '%s.%s'. Current database id is [%s].\" thrown in mybatis/mybatis-3.","triggerScenarios":"Thrown at src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java:687 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a statement annotation (e.g. @Select) without a databaseId so it serves as the default for the method.","Add a statement annotation whose databaseId matches the current database id shown in the message.","Verify the configured databaseId in your MyBatis configuration matches the databaseId used on the annotation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}