{"record":{"id":"9a0ff4e4c5892dae","repo":"mybatis/mybatis-3","slug":"detected-conflicting-annotations-s-and-s-on","errorCode":null,"errorMessage":"Detected conflicting annotations '%s' and '%s' on '%s'.","messagePattern":"Detected conflicting annotations '(.+?)' and '(.+?)' on '(.+?)'\\.","errorType":"exception","errorClass":"BuilderException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java","lineNumber":674,"sourceCode":"  private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass,\n      ParamNameResolver paramNameResolver, LanguageDriver languageDriver) {\n    return languageDriver.createSqlSource(configuration, String.join(\" \", strings).trim(), parameterTypeClass,\n        paramNameResolver);\n  }\n\n  @SafeVarargs\n  private final Optional<AnnotationWrapper> getAnnotationWrapper(Method method, boolean errorIfNoMatch,\n      Class<? extends Annotation>... targetTypes) {\n    return getAnnotationWrapper(method, errorIfNoMatch, Arrays.asList(targetTypes));\n  }\n\n  private Optional<AnnotationWrapper> getAnnotationWrapper(Method method, boolean errorIfNoMatch,\n      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  }","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java#L656-L692","documentation":"Error \"Detected conflicting annotations '%s' and '%s' on '%s'.\" thrown in mybatis/mybatis-3.","triggerScenarios":"Thrown at src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java:674 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove one of the conflicting annotations from the method so only one remains.","If both annotations are needed, refactor the method into two separate mapper methods each carrying one annotation.","Check the MyBatis documentation for the pair of annotations reported; they are mutually exclusive by design."],"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"}