mybatis/mybatis-3 · error · BuilderException

Error creating SqlSource for SqlProvider. Method

Error message

Error creating SqlSource for SqlProvider. Method '{methodName}' is found multiple in SqlProvider '{providerTypeName}'. Sql provider method can not overload.

What it means

Error "Error creating SqlSource for SqlProvider. Method '{methodName}' is found multiple in SqlProvider '{providerTypeName}'. Sql provider method can not overload." thrown in mybatis/mybatis-3.

Solutions

  1. Remove the overloaded provider method so only one method with the reported name exists in the SqlProvider class.
  2. Sql provider methods cannot be overloaded; consolidate the overloads into one method and branch on the arguments inside it.

When it happens

Trigger: Thrown at src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14). Data as JSON: /api/errors/79bf2ee11828c3a8. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java:123

      this.mapperMethod = mapperMethod;
      Lang lang = mapperMethod == null ? null : mapperMethod.getAnnotation(Lang.class);
      this.languageDriver = configuration.getLanguageDriver(lang == null ? null : lang.value());
      this.providerType = getProviderType(configuration, provider, mapperMethod);
      candidateProviderMethodName = (String) provider.annotationType().getMethod("method").invoke(provider);

      if (candidateProviderMethodName.length() == 0
          && ProviderMethodResolver.class.isAssignableFrom(this.providerType)) {
        candidateProviderMethod = ((ProviderMethodResolver) this.providerType.getDeclaredConstructor().newInstance())
            .resolveMethod(new ProviderContext(mapperType, mapperMethod, configuration.getDatabaseId()));
      }
      if (candidateProviderMethod == null) {
        candidateProviderMethodName = candidateProviderMethodName.length() == 0 ? "provideSql"
            : candidateProviderMethodName;
        for (Method m : this.providerType.getMethods()) {
          if (candidateProviderMethodName.equals(m.getName())
              && CharSequence.class.isAssignableFrom(m.getReturnType())) {
            if (candidateProviderMethod != null) {
              throw new BuilderException("Error creating SqlSource for SqlProvider. Method '"
                  + candidateProviderMethodName + "' is found multiple in SqlProvider '" + this.providerType.getName()
                  + "'. Sql provider method can not overload.");
            }
            candidateProviderMethod = m;
          }
        }
      }
    } catch (BuilderException e) {
      throw e;
    } catch (Exception e) {
      throw new BuilderException("Error creating SqlSource for SqlProvider.  Cause: " + e, e);
    }
    if (candidateProviderMethod == null) {
      throw new BuilderException("Error creating SqlSource for SqlProvider. Method '" + candidateProviderMethodName
          + "' not found in SqlProvider '" + this.providerType.getName() + "'.");
    }
    this.providerMethod = candidateProviderMethod;
    this.paramNameResolver = new ParamNameResolver(configuration, this.providerMethod, mapperType);

View on GitHub (pinned to 008069adb1)