{"record":{"id":"9811a8781c5893bd","repo":"mybatis/mybatis-3","slug":"cannot-specify-different-class-on-value-and-typ","errorCode":null,"errorMessage":"Cannot specify different class on 'value' and 'type' attribute of @{annotationSimpleName} at the '{mapperMethod}'.","messagePattern":"Cannot specify different class on 'value' and 'type' attribute of @(.+?) at the '(.+?)'\\.","errorType":"exception","errorClass":"BuilderException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java","lineNumber":265,"sourceCode":"      targetObject = providerType.getDeclaredConstructor().newInstance();\n    }\n    CharSequence sql = (CharSequence) providerMethod.invoke(targetObject, args);\n    return sql != null ? sql.toString() : null;\n  }\n\n  private Class<?> getProviderType(Configuration configuration, Annotation providerAnnotation, Method mapperMethod)\n      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {\n    Class<?> type = (Class<?>) providerAnnotation.annotationType().getMethod(\"type\").invoke(providerAnnotation);\n    Class<?> value = (Class<?>) providerAnnotation.annotationType().getMethod(\"value\").invoke(providerAnnotation);\n    if (value == void.class && type == void.class) {\n      if (configuration.getDefaultSqlProviderType() != null) {\n        return configuration.getDefaultSqlProviderType();\n      }\n      throw new BuilderException(\"Please specify either 'value' or 'type' attribute of @\"\n          + providerAnnotation.annotationType().getSimpleName() + \" at the '\" + mapperMethod.toString() + \"'.\");\n    }\n    if (value != void.class && type != void.class && value != type) {\n      throw new BuilderException(\"Cannot specify different class on 'value' and 'type' attribute of @\"\n          + providerAnnotation.annotationType().getSimpleName() + \" at the '\" + mapperMethod.toString() + \"'.\");\n    }\n    return value == void.class ? type : value;\n  }\n\n}\n","sourceCodeStart":247,"sourceCodeEnd":272,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java#L247-L272","documentation":"Error \"Cannot specify different class on 'value' and 'type' attribute of @{annotationSimpleName} at the '{mapperMethod}'.\" thrown in mybatis/mybatis-3.","triggerScenarios":"Thrown at src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java:265 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only one of value or type on the provider annotation, or make both reference the same provider class.","Remove the duplicate attribute so a single provider class is specified."],"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"}