{"record":{"id":"ee8b92f5589dbed3","repo":"mybatis/mybatis-3","slug":"cannot-resolve-the-provider-method-because-metho-ee8b92","errorCode":null,"errorMessage":"Cannot resolve the provider method because '{methodName}' does not return the CharSequence or its subclass in SqlProvider '{className}'.","messagePattern":"Cannot resolve the provider method because '(.+?)' does not return the CharSequence or its subclass in SqlProvider '(.+?)'\\.","errorType":"exception","errorClass":"BuilderException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java","lineNumber":68,"sourceCode":"   * @return an SQL provider method\n   *\n   * @throws BuilderException\n   *           Throws when cannot resolve a target method\n   */\n  default Method resolveMethod(ProviderContext context) {\n    List<Method> sameNameMethods = Arrays.stream(getClass().getMethods())\n        .filter(m -> m.getName().equals(context.getMapperMethod().getName())).collect(Collectors.toList());\n    if (sameNameMethods.isEmpty()) {\n      throw new BuilderException(\"Cannot resolve the provider method because '\" + context.getMapperMethod().getName()\n          + \"' not found in SqlProvider '\" + getClass().getName() + \"'.\");\n    }\n    List<Method> targetMethods = sameNameMethods.stream()\n        .filter(m -> CharSequence.class.isAssignableFrom(m.getReturnType())).collect(Collectors.toList());\n    if (targetMethods.size() == 1) {\n      return targetMethods.get(0);\n    }\n    if (targetMethods.isEmpty()) {\n      throw new BuilderException(\"Cannot resolve the provider method because '\" + context.getMapperMethod().getName()\n          + \"' does not return the CharSequence or its subclass in SqlProvider '\" + getClass().getName() + \"'.\");\n    }\n    throw new BuilderException(\"Cannot resolve the provider method because '\" + context.getMapperMethod().getName()\n        + \"' is found multiple in SqlProvider '\" + getClass().getName() + \"'.\");\n  }\n\n}\n","sourceCodeStart":50,"sourceCodeEnd":76,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java#L50-L76","documentation":"Error \"Cannot resolve the provider method because '{methodName}' does not return the CharSequence or its subclass in SqlProvider '{className}'.\" thrown in mybatis/mybatis-3.","triggerScenarios":"Thrown at src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the provider method's return type to String (or another CharSequence subclass) that returns the SQL text.","Return the SQL statement as a String instead of a non-character type such as a StringBuilder field or object."],"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"}