mybatis/mybatis-3 · error · BuilderException

Error resolving ParameterMode. Cause

Error message

Error resolving ParameterMode. Cause: {cause}

What it means

BaseBuilder.resolveParameterMode() converts the parameterMode attribute of <parameter> elements into the ParameterMode enum (IN, OUT, INOUT) via valueOf(). Any value outside those three constants fails parsing with this BuilderException.

Solutions

  1. Use exactly IN, OUT, or INOUT as the parameterMode value
  2. For stored function return values, use the standard #{result, mode=OUT, jdbcType=...} pattern or a result map rather than inventing a mode

Example fix

<!-- before -->
<parameter property="total" parameterMode="IN_OUT"/>
<!-- after -->
<parameter property="total" parameterMode="INOUT"/>
Defensive patterns

Strategy: validation

Validate before calling

static final Set<String> VALID = Set.of("IN", "OUT", "INOUT");
if (!VALID.contains(mode)) throw new IllegalArgumentException(mode);

Prevention

When it happens

Trigger: parameterMode="IN_OUT" (underscore typo; correct is INOUT); parameterMode="RETURN" on legacy stored-proc parameter maps; lowercase 'in'.

Common situations: Writing stored-procedure <parameterMap> entries by hand; migrating old iBATIS parameter maps with informal mode names.

Related errors


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

Appendix: source

Thrown at src/main/java/org/apache/ibatis/builder/BaseBuilder.java:87

      return alias == null ? null : JdbcType.valueOf(alias);
    } catch (IllegalArgumentException e) {
      throw new BuilderException("Error resolving JdbcType. Cause: " + e, e);
    }
  }

  protected ResultSetType resolveResultSetType(String alias) {
    try {
      return alias == null ? null : ResultSetType.valueOf(alias);
    } catch (IllegalArgumentException e) {
      throw new BuilderException("Error resolving ResultSetType. Cause: " + e, e);
    }
  }

  protected ParameterMode resolveParameterMode(String alias) {
    try {
      return alias == null ? null : ParameterMode.valueOf(alias);
    } catch (IllegalArgumentException e) {
      throw new BuilderException("Error resolving ParameterMode. Cause: " + e, e);
    }
  }

  protected Object createInstance(String alias) {
    Class<?> clazz = resolveClass(alias);
    try {
      return clazz == null ? null : clazz.getDeclaredConstructor().newInstance();
    } catch (Exception e) {
      throw new BuilderException("Error creating instance. Cause: " + e, e);
    }
  }

  protected <T> Class<? extends T> resolveClass(String alias) {
    try {
      return alias == null ? null : resolveAlias(alias);
    } catch (Exception e) {
      throw new BuilderException("Error resolving class. Cause: " + e, e);
    }

View on GitHub (pinned to 008069adb1)