{"record":{"id":"2244a3430b6841db","repo":"mybatis/mybatis-3","slug":"could-not-find-a-parent-resultmap-with-id-extend","errorCode":null,"errorMessage":"Could not find a parent resultMap with id '{extend}'","messagePattern":"Could not find a parent resultMap with id '(.+?)'","errorType":"exception","errorClass":"IncompleteElementException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java","lineNumber":164,"sourceCode":"      Integer numericScale) {\n    resultMap = applyCurrentNamespace(resultMap, true);\n\n    // Class parameterType = parameterMapBuilder.type();\n    Class<?> javaTypeClass = resolveParameterJavaType(parameterType, property, javaType, jdbcType);\n    TypeHandler<?> typeHandlerInstance = resolveTypeHandler(javaTypeClass, jdbcType, typeHandler);\n\n    return new ParameterMapping.Builder(configuration, property, javaTypeClass).jdbcType(jdbcType)\n        .resultMapId(resultMap).mode(parameterMode).numericScale(numericScale).typeHandler(typeHandlerInstance).build();\n  }\n\n  public ResultMap addResultMap(String id, Class<?> type, String extend, Discriminator discriminator,\n      List<ResultMapping> resultMappings, Boolean autoMapping) {\n    id = applyCurrentNamespace(id, false);\n    extend = applyCurrentNamespace(extend, true);\n\n    if (extend != null) {\n      if (!configuration.hasResultMap(extend)) {\n        throw new IncompleteElementException(\"Could not find a parent resultMap with id '\" + extend + \"'\");\n      }\n      ResultMap resultMap = configuration.getResultMap(extend);\n      List<ResultMapping> extendedResultMappings = new ArrayList<>(resultMap.getResultMappings());\n      extendedResultMappings.removeAll(resultMappings);\n      // Remove parent constructor if this resultMap declares a constructor.\n      boolean declaresConstructor = false;\n      for (ResultMapping resultMapping : resultMappings) {\n        if (resultMapping.getFlags().contains(ResultFlag.CONSTRUCTOR)) {\n          declaresConstructor = true;\n          break;\n        }\n      }\n      if (declaresConstructor) {\n        extendedResultMappings.removeIf(resultMapping -> resultMapping.getFlags().contains(ResultFlag.CONSTRUCTOR));\n      }\n      resultMappings.addAll(extendedResultMappings);\n    }\n    ResultMap resultMap = new ResultMap.Builder(configuration, id, type, resultMappings, autoMapping)","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java#L146-L182","documentation":"Thrown by addResultMap() when a <resultMap extends=\"...\"> references a parent resultMap id that configuration.hasResultMap() cannot find at that moment. It is an IncompleteElementException: MyBatis collects the incomplete result map and retries after all mappers are parsed, because the parent frequently lives in a mapper parsed later. It becomes fatal only if the parent never appears.","triggerScenarios":"<resultMap id=\"x\" extends=\"someMissing.Map\">, or extends pointing at a parent in another mapper file that is parsed later or not registered at all; also an extends value whose namespace prefix is wrong after applyCurrentNamespace(extend, true).","commonSituations":"Cross-mapper inheritance ordering during startup (usually self-heals), dangling extends after deleting/renaming a parent resultMap, or a typo in the parent id. Persistent failure means the parent is genuinely absent from the Configuration.","solutions":["Verify the parent resultMap id and its namespace spelling; use the fully qualified name when the parent is in another mapper","Make sure the mapper containing the parent is registered (mybatis-config.xml <mapper> entries, package scanning, or Spring mybatis mapperLocations covering the file)","If the parent was renamed/removed, update or delete the extends attribute"],"exampleFix":"<!-- before -->\n<resultMap id=\"extUser\" type=\"User\" extends=\"com.acme.BaseUserr\">\n<!-- after -->\n<resultMap id=\"extUser\" type=\"User\" extends=\"com.acme.BaseUser\">","handlingStrategy":"validation","validationCode":"// After building Configuration, assert every resultMap 'extends' resolved\nconfiguration.getResultMapNames().forEach(rmId -> {\n  // MyBatis flattens inheritance at build time; simply assert referenced ids exist before build:\n});\n// pre-build check on the XML side:\nfor (Map.Entry<String, String> e : collectExtendsRefs()) { // childId -> parentId\n  if (!definedResultMapIds.contains(e.getValue())) {\n    throw new IllegalStateException(\"resultMap '\" + e.getKey() + \"' extends unknown '\" + e.getValue() + \"'\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  factory = new SqlSessionFactoryBuilder().build(configInputStream);\n} catch (PersistenceException e) {\n  Throwable root = ExceptionUtils.getRootCause(e);\n  if (root.getMessage().contains(\"Could not find a parent resultMap\")) {\n    throw new ConfigurationException(\"Dangling resultMap extends: \" + root.getMessage(), root);\n  }\n  throw e;\n}","preventionTips":["Prefer fully-qualified parent ids in extends attributes","When deleting/renaming a base resultMap, grep the whole project for its id","Build the SqlSessionFactory in a unit test so inheritance issues surface at build time"],"tags":["mybatis","resultmap","inheritance","incomplete-element"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}