{"record":{"id":"e318abe75beabdd2","repo":"mybatis/mybatis-3","slug":"please-specify-either-value-or-type-attribute","errorCode":null,"errorMessage":"Please specify either 'value' or 'type' attribute of @{annotationSimpleName} at the '{mapperMethod}'.","messagePattern":"Please specify either 'value' or '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":261,"sourceCode":"\n  private String invokeProviderMethod(Object... args) throws Exception {\n    Object targetObject = null;\n    if (!Modifier.isStatic(providerMethod.getModifiers())) {\n      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":243,"sourceCodeEnd":272,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java#L243-L272","documentation":"Error \"Please specify either 'value' or '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:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set either the value or the type attribute on the provider annotation to point at the SqlProvider class.","Example: @SelectProvider(type = MyProvider.class, method = \"provideSql\")."],"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-15T17:31:12.345Z"}