{"record":{"id":"4ae7e302f2ff07d6","repo":"hibernate/hibernate-orm","slug":"convert-annotation-for-map-role-must-specif","errorCode":null,"errorMessage":"'@Convert' annotation for map [<role>] must specify 'attributeName=\"key\"' or 'attributeName=\"value\"'","messagePattern":"'@Convert' annotation for map \\[<role>\\] must specify 'attributeName=\"key\"' or 'attributeName=\"value\"'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java","lineNumber":176,"sourceCode":"\t\t\telse if ( elementPath != null ) {\n\t\t\t\telementAttributeConversionInfoMap.put( elementPath, info );\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// specified attributeName needs to have 'key.' or 'value.' prefix\n\t\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"Could not determine how to apply @Convert(attributeName='%s') to collection [%s]\",\n\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\tcollection.getRole()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void throwMissingAttributeName() {\n\t\tthrow new IllegalStateException( \"'@Convert' annotation for map [\" + collection.getRole()\n\t\t\t\t\t\t\t\t\t+ \"] must specify 'attributeName=\\\"key\\\"' or 'attributeName=\\\"value\\\"'\" );\n\t}\n\n\tprivate static void logSpecNoncompliance(String attributeName, String role) {\n\t\tfinal boolean specCompliant = isNotEmpty( attributeName )\n\t\t\t\t&& (attributeName.startsWith( \"key\" ) || attributeName.startsWith( \"value\" ) );\n\t\tif ( !specCompliant ) {\n\t\t\tBOOT_LOGGER.nonCompliantMapConversion( role );\n\t\t}\n\t}\n\n\t/**\n\t * Check if path has the given prefix and remove it.\n\t *\n\t * @param path Path.\n\t * @param prefix Prefix.\n\t * @return Path without prefix, or null, if path did not have the prefix.\n\t */","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java#L158-L194","documentation":"Error \"'@Convert' annotation for map [<role>] must specify 'attributeName=\"key\"' or 'attributeName=\"value\"'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A @Convert / AttributeConverter declaration is missing required information or applies to a target that forbids conversion.","commonSituations":"@Convert without attributeName on a class-level or embedded target, or a converter clashing with a mapping annotation like @Enumerated/@Temporal that requires disableConversion=true.","solutions":["Set @Convert(attributeName=\"key\") or @Convert(attributeName=\"value\") for the map mapping."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}