{"record":{"id":"9e5b8a7367283abd","repo":"mybatis/mybatis-3","slug":"error-in-result-map-resultmapid-we-do-not-sup","errorCode":null,"errorMessage":"Error in result map '{resultMapId}'. We do not support partially specifying a property name nor duplicates. Either specify all property names, or none.","messagePattern":"Error in result map '(.+?)'\\. We do not support partially specifying a property name nor duplicates\\. Either specify all property names, or none\\.","errorType":"exception","errorClass":"BuilderException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/ResultMappingConstructorResolver.java","lineNumber":158,"sourceCode":"    final List<ResultMapping> resultMappings = autoTypeRequired\n        ? autoTypeConstructorMappings(matchingConstructorInfo, constructorResultMappings, allMappingsHavePropertyNames)\n        : constructorResultMappings;\n\n    if (allMappingsHavePropertyNames) {\n      // finally sort them based on the constructor meta info\n      sortConstructorMappings(matchingConstructorInfo, resultMappings);\n    }\n\n    return resultMappings;\n  }\n\n  private boolean verifyPropertyNaming(Set<String> constructorArgsByName) {\n    final boolean allMappingsHavePropertyNames = constructorResultMappings.size() == constructorArgsByName.size();\n\n    // If property names have been partially specified, throw an exception, as this case does not make sense\n    // either specify all names and (optional random order), or type info.\n    if (!allMappingsHavePropertyNames && !constructorArgsByName.isEmpty()) {\n      throw new BuilderException(\"Error in result map '\" + resultMapId\n          + \"'. We do not support partially specifying a property name nor duplicates. Either specify all property names, or none.\");\n    }\n\n    return allMappingsHavePropertyNames;\n  }\n\n  List<ConstructorMetaInfo> retrieveConstructorCandidates(int withLength) {\n    return Arrays.stream(resultType.getDeclaredConstructors())\n        .filter(constructor -> constructor.getParameterTypes().length == withLength).map(ConstructorMetaInfo::new)\n        .collect(Collectors.toList());\n  }\n\n  private static void removeCandidatesBasedOnParameterNames(List<ConstructorMetaInfo> matchingConstructorCandidates,\n      Set<String> constructorArgsByName) {\n    final Iterator<ConstructorMetaInfo> candidateIterator = matchingConstructorCandidates.iterator();\n    while (candidateIterator.hasNext()) {\n      // extract the names (and types) the constructor has\n      final ConstructorMetaInfo candidateInfo = candidateIterator.next();","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/ResultMappingConstructorResolver.java#L140-L176","documentation":"Thrown by ResultMappingConstructorResolver.verifyPropertyNaming(): within a <constructor> mapping, some (but not all) <arg> elements carry a name attribute, or duplicates exist, so the count of collected names differs from the number of constructor mappings. MyBatis requires name attributes on either all args (name-based matching) or none (type/order-based matching), never a mix.","triggerScenarios":"<constructor><arg column=\"a\" name=\"x\"/><arg column=\"b\"/></constructor> — one arg named, the other anonymous; or two args with the same name (the Set used for names shrinks the count and trips the same check).","commonSituations":"Incrementally adding a new <arg> to an existing constructor mapping and forgetting its name; copy-paste leaving duplicate names; merging mapper changes where naming style differs.","solutions":["Either add name attributes to every <arg> in the constructor block, or remove them all","Ensure names are unique across args in the same constructor","When going name-less, supply javaType on each arg so positional/type matching still works"],"exampleFix":"<!-- before -->\n<constructor>\n  <arg column=\"id\" name=\"id\"/>\n  <arg column=\"user_name\"/>\n</constructor>\n<!-- after -->\n<constructor>\n  <arg column=\"id\" name=\"id\"/>\n  <arg column=\"user_name\" name=\"userName\"/>\n</constructor>","handlingStrategy":"validation","validationCode":"// XML-side check: within <constructor>, either all <arg> have name or none, and names unique\nElement ctor = (Element) resultMapEl.getElementsByTagName(\"constructor\").item(0);\nif (ctor != null) {\n  List<Element> args = asList(ctor.getElementsByTagName(\"arg\"));\n  long named = args.stream().filter(a -> a.hasAttribute(\"name\")).count();\n  Set<String> names = args.stream().filter(a -> a.hasAttribute(\"name\"))\n      .map(a -> a.getAttribute(\"name\")).collect(Collectors.toSet());\n  if (named != 0 && named != args.size()) throw new IllegalStateException(\"Mixed named/unnamed constructor args\");\n  if (names.size() != named) throw new IllegalStateException(\"Duplicate constructor arg names\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one style per constructor block: all named or all typed; never mix","When adding an <arg>, copy the name attribute convention of its siblings"],"tags":["mybatis","resultmap","constructor-mapping","configuration"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}